Advertisement
Guest User

Untitled

a guest
Oct 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. def startup():
  2. with open('Admin.txt', 'w+') as q:
  3. q.write('Admin : Password')
  4. with open("Admin.txt", 'a+') as r:
  5. r.read()
  6. print ("Admin Username and Password has been set")
  7. home()
  8.  
  9. def home():
  10. print("Do you want to create a new user (guest) or Log In?")
  11. log_user = input()
  12. if log_user == "Log In":
  13. login()
  14. elif log_user == "new user":
  15. new_user_maker()
  16. else:
  17. print ("Sorry that was not a valid option please try again")
  18. home()
  19.  
  20. def new_user_maker():
  21. print("What is your name?")
  22. name = input()
  23. print("What is your age?")
  24. age = input()
  25. new_guest_user = name[0:3] + age
  26. print("Your username is: ", new_guest_user)
  27. print("What do you want as a password?")
  28. new_guest_pass = input()
  29. with open(new_guest_user + '.db', 'w') as w:
  30. w.write(new_guest_user + " : " + new_guest_pass)
  31. login()
  32.  
  33. def login():
  34. print("You will now log in")
  35. print("Are you a Admin or Guest? ")
  36. user_type = input()
  37. if user_type == 'Admin':
  38. Admin_login()
  39. elif user_type == 'Guest':
  40. Guest_login()
  41. else:
  42. print("That is not an valid option sorry, please specify 'Admin' or 'Guest'")
  43. login()
  44.  
  45. def Admin_login():
  46. print("You chose to be an admin")
  47. print("Please input your username: ")
  48. Admin_Name = input()
  49. print("Please input your password: ")
  50. Admin_Password = input()
  51. try:
  52. filename = Admin_Name + ".txt"
  53. with open(filename, 'r') as checking_user_and_pass:
  54. Admin_correct = checking_user_and_pass.read()
  55. if Admin_correct == Admin_Name + " : " + Admin_Password:
  56. print("You are now logged in as an admin")
  57. else:
  58. print ('Incorrect Username or Password')
  59. print ("Do you want to Try Again or log in as a different user")
  60. option = input ()
  61. if option == 'Try Again':
  62. Admin_login()
  63. except:
  64. print ('Incorrect Username or Password')
  65. print ("Do you want to Try Again or Log In as a different user")
  66. option = input()
  67. if option == "Try Again":
  68. Admin_login()
  69. else:
  70. print("You chose to be a different user")
  71. login()
  72.  
  73. def Guest_login():
  74. print("You chose to be a guest")
  75. print("Please input your username: ")
  76. Guest_Name = input()
  77. print("Please input your password: ")
  78. Guest_Password = input()
  79. try:
  80. filename = Guest_Name + ".db"
  81. with open(filename, 'r') as checking_user_and_pass:
  82. Guest_correct = checking_user_and_pass.read()
  83. if Guest_correct == Guest_Name + " : " + Guest_Password:
  84. print("You are now logged in as", Guest_Name)
  85. else:
  86. print ('Incorrect Username or Password')
  87. print ("Do you want to Try Again or log in as a different user")
  88. option = input ()
  89. if option == 'Try Again':
  90. Guest_login()
  91. except:
  92. print ('Incorrect Username or Password')
  93. print ("Do you want to Try Again or Log In as a different user")
  94. option = input()
  95. if option == "Try Again":
  96. Guest_login()
  97. else:
  98. print("You chose to be a different user")
  99. login()
  100.  
  101. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement