Advertisement
Guest User

Username and Password Code

a guest
Apr 30th, 2019
5,831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. # USERNAME AND PASSWORD CHECK WITH ATTEMPT COUNT
  2. import sys
  3. print ('Welcome to your program! We need to check some things to make sure it\'s you.')
  4. usercount=0
  5. passcount=0
  6. # username input and check
  7. while True:
  8.     print ('What is your username?')
  9.     username = input()
  10.     if username == 'user':
  11.         print ('Correct.')
  12.         break
  13.     elif username!='user':
  14.         usercount+=1
  15.         print ('Incorrect.')
  16.         if usercount>2:
  17.             print('Too many attempts! Goodbye!')
  18.             sys.exit()
  19. # password input and check      
  20. while True:
  21.     print ('What is your password?')
  22.     password = input()
  23.     if password == '123':
  24.         print ('Correct.')
  25.         break
  26.     elif password!='123':
  27.         passcount+=1
  28.         print ('Incorrect.')
  29.         if passcount>2:
  30.             print ('Too many attempts! Goodbye!')
  31.             sys.exit()
  32.  
  33. if username == 'user' and password == '123':
  34.     print ('Access Granted!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement