Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import time
- def main_menu():
- print("----- MAIN MENU -----\n")
- print("- Login")
- print("- Signup")
- print("- Quit\n")
- print("----- MAIN MENU -----\n")
- choices = {
- 'login': login_menu,
- 'signup': signup_menu,
- 'quit': sys.exit
- }
- while True:
- userchoice = input("> ").lower()
- if userchoice not in choices:
- print("Invalid Response.")
- continue
- action = choices[userchoice]
- action()
- def login_menu():
- supplied_username = input("Enter a username: ")
- supplied_password =input("Enter a password: ")
- with open(supplied_username + "_details.txt", "r") as file:
- for line in file:
- username, password = line.split(",")
- if username == supplied_username:
- logged_in = password == supplied_password
- print("Welcome",username)
- main_Screen()
- else:
- print("Incorrect details")
- login_menu()
- def signup_menu():
- username = input("Enter a username: ")
- password =input("Enter a password: ")
- infofile = open(username + "_details.txt", "a")
- infofile.write(username + "," + password + "\n")
- infofile.close()
- time.sleep(1)
- print("Account Created!")
- time.sleep(1)
- main_menu()
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement