Advertisement
Guest User

Untitled

a guest
May 4th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 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.  
  22. def checkun(un):
  23. if un in d:
  24. return True
  25. else:
  26. return False
  27. def update_database():
  28. file = open("password.txt",w)
  29. file.write(d.values())
  30. file.close()
  31.  
  32.  
  33. def display_menu():
  34. print("MAIN MENU : ")
  35. print('A.Investment Projection')
  36. print('B.Rettirement Planning')
  37. print('C.Mortgage')
  38. print('D.College Fund')
  39. print('E.Exit')
  40.  
  41. def main():
  42. with open("user.txt") as f:
  43. A = [str(x) for x in f.read().split()]
  44.  
  45. with open("password.txt") as j:
  46. B = [str(x) for x in j.read().split()]
  47.  
  48.  
  49. lenA=len(A)
  50. for i in range(lenA):
  51. d[A[i]]=B[i]
  52. print(d)
  53.  
  54. un=input('enter your username:')
  55. pw=input('enter your password:')
  56. while(not(checkun(un))):
  57. un=input('enter your username:')
  58. pw=input('enter your password:')
  59. user_input(3,un,pw)
  60.  
  61. d={}
  62. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement