Advertisement
Guest User

Untitled

a guest
Nov 24th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import sys # imported this module to use sys.exit() below - read about it in the chapter.
  2.  
  3. account = 'user'
  4. password1 = 'pass'
  5.  
  6. while True:
  7.    print('Please provide user name: ')
  8.    username = input()
  9.    if username == account:
  10.       for t in range(3):
  11.          print('Welcome ' + account + '  Please provide your password: ')
  12.          password = input()
  13.          if password == password1:
  14.             print('Welcome ' + account + '. You are now in the system')
  15.             sys.exit() # the only way to exit the big while True: loop, otherwise breaking out of here returns to the big loop
  16.          else:
  17.             print('Incorrect password.' + ' This is your ' + str(t + 1) + ' try.')
  18.             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
  19.               print('You have gone over the maximum amount of tries for ' + account + ' You are logged out.')
  20.               break
  21.    else:
  22.       print('User does not exist.\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement