Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def intro():
- print("\nEnter your details to login \n")
- def login():
- # Opens the user.txt file
- with(open('uid.txt', 'r+')) as u_name:
- a = u_name.read()
- uid = a.split()
- uid_low = [item.lower() for item in uid]
- # Opens the passwords.txt file
- with(open('pwd.txt', 'r+')) as u_pass:
- a = u_pass.read()
- pwd = a.split()
- # Takes user input
- u = input('Enter your username: ')
- u1 = u.lower()
- p = input('Enter your password: ')
- bo = False
- if u1 in uid_low:
- bo = True
- '''Checks if user exists or not'''
- if bo is True:
- bo = True
- else:
- print('User does not exist')
- '''Finds the index of user'''
- i = uid_low.index(u1)
- '''Checks if password is correct or not'''
- if p == pwd[i]:
- print('Welcome', u)
- print('Successfully logged in. ')
- else:
- m = 3
- n = 3
- while p != pwd[i]:
- print("Password doesn't match \n")
- print('You have', n, 'tries left.')
- n -= 1
- p = input('Re-enter your password: ')
- if p == pwd[i]:
- print('You entered incorrect passwords', m - n, 'times.\n')
- print('Successfully logged in. Welcome', u)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement