Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys # imported this module to use sys.exit() below - read about it in the chapter.
- account = 'user'
- password1 = 'pass'
- while True:
- print('Please provide user name: ')
- username = input()
- if username == account:
- for t in range(3):
- print('Welcome ' + account + ' Please provide your password: ')
- password = input()
- if password == password1:
- print('Welcome ' + account + '. You are now in the system')
- sys.exit() # the only way to exit the big while True: loop, otherwise breaking out of here returns to the big loop
- else:
- print('Incorrect password.' + ' This is your ' + str(t + 1) + ' try.')
- if t == 2: # changed this part to compare the counter and deliver a proper error msg, then return to asking for a user in the big loop
- print('You have gone over the maximum amount of tries for ' + account + ' You are logged out.')
- break
- else:
- print('User does not exist.\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement