Advertisement
Guest User

Untitled

a guest
Sep 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. import sys
  2. import time
  3.  
  4. def main_menu():
  5.     print("----- MAIN MENU -----\n")
  6.     print("- Login")
  7.     print("- Signup")
  8.     print("- Quit\n")
  9.     print("----- MAIN MENU -----\n")
  10.  
  11.     choices = {
  12.         'login': login_menu,
  13.         'signup': signup_menu,
  14.         'quit': sys.exit
  15.     }
  16.  
  17.     while True:
  18.         userchoice = input("> ").lower()
  19.         if userchoice not in choices:
  20.             print("Invalid Response.")
  21.             continue
  22.         action = choices[userchoice]
  23.         action()
  24.  
  25. def login_menu():
  26.     supplied_username = input("Enter a username: ")
  27.     supplied_password =input("Enter a password: ")
  28.     with open(supplied_username + "_details.txt", "r") as file:
  29.         for line in file:
  30.             username, password = line.split(",")
  31.             if username == supplied_username:
  32.                 logged_in = password == supplied_password
  33.                 print("Welcome",username)
  34.                 main_Screen()
  35.             else:
  36.                 print("Incorrect details")
  37.                 login_menu()
  38.  
  39.  
  40.  
  41. def signup_menu():
  42.     username = input("Enter a username: ")
  43.     password =input("Enter a password: ")
  44.     infofile = open(username + "_details.txt", "a")
  45.     infofile.write(username + "," + password + "\n")
  46.     infofile.close()
  47.     time.sleep(1)
  48.     print("Account Created!")
  49.     time.sleep(1)
  50.     main_menu()
  51.    
  52. main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement