Advertisement
Guest User

Untitled

a guest
May 4th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1.  
  2.  
  3. def user_input(x,un,pw):
  4. if (x==0):
  5. print("password incorrect ")
  6. changepw(un)
  7. user_input(3,un,pw)
  8. else:
  9. if d[un]==pw:
  10. print("correct password:"+pw)
  11. display_menu()
  12. else:
  13. pw=input('invalid password, enter password again : ')
  14. user_input(x-1,un,pw)
  15.  
  16. def changepw(un):
  17. npw=(input('Invalid password- enter new password to update account : '))
  18. d[un]=npw
  19. update_database()
  20.  
  21. def checkun(un):
  22. if un in d:
  23. return True
  24. else:
  25. return False
  26. def update_database():
  27. file = open(β€œpassword.txt”,”w”)
  28. file.write(d.values())
  29.  
  30.  
  31. def display_menu():
  32. print("MAIN MENU : ")
  33. print('A.Investment Projection')
  34. print('B.Rettirement Planning')
  35. print('C.Mortgage')
  36. print('D.College Fund')
  37. print('E.Exit')
  38.  
  39. def main():
  40. with open("user.txt") as f:
  41. A = [str(x) for x in f.read().split()]
  42.  
  43. with open("password.txt") as j:
  44. B = [str(x) for x in j.read().split()]
  45.  
  46.  
  47. lenA=len(A)
  48. for i in range(lenA):
  49. d[A[i]]=B[i]
  50. print(d)
  51.  
  52. un=input('enter your username:')
  53. pw=input('enter your password:')
  54. while(not(checkun(un))):
  55. print("username does not exist")
  56. un=input('enter your username:')
  57. pw=input('enter your password:')
  58. user_input(3,un,pw)
  59.  
  60. d={}
  61. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement