Advertisement
Guest User

Untitled

a guest
Dec 21st, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. def intro():
  2. print("\nEnter your details to login \n")
  3.  
  4.  
  5. def login():
  6. # Opens the user.txt file
  7. with(open('uid.txt', 'r+')) as u_name:
  8. a = u_name.read()
  9. uid = a.split()
  10. uid_low = [item.lower() for item in uid]
  11.  
  12. # Opens the passwords.txt file
  13. with(open('pwd.txt', 'r+')) as u_pass:
  14. a = u_pass.read()
  15. pwd = a.split()
  16.  
  17. # Takes user input
  18. u = input('Enter your username: ')
  19. u1 = u.lower()
  20. p = input('Enter your password: ')
  21. bo = False
  22.  
  23. if u1 in uid_low:
  24. bo = True
  25.  
  26. '''Checks if user exists or not'''
  27. if bo is True:
  28. bo = True
  29. else:
  30. print('User does not exist')
  31.  
  32. '''Finds the index of user'''
  33. i = uid_low.index(u1)
  34.  
  35. '''Checks if password is correct or not'''
  36. if p == pwd[i]:
  37. print('Welcome', u)
  38. print('Successfully logged in. ')
  39. else:
  40. m = 3
  41. n = 3
  42. while p != pwd[i]:
  43. print("Password doesn't match \n")
  44. print('You have', n, 'tries left.')
  45. n -= 1
  46. p = input('Re-enter your password: ')
  47. if p == pwd[i]:
  48. print('You entered incorrect passwords', m - n, 'times.\n')
  49. print('Successfully logged in. Welcome', u)
  50. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement