Guest User

sample_username_password_program

a guest
Dec 17th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import sys
  2. incorrect = 0
  3. max_tries = 6
  4.  
  5. choices = ['Drake', 'swordfish']
  6.  
  7. run = True
  8.  
  9. while run:
  10.     while incorrect < max_tries:
  11.         user_input = input('Please enter username: ')
  12.         if user_input not in choices:
  13.             incorrect += 1
  14.             print(f"{user_input} is incorrect. Please try again.")
  15.         else:
  16.             print(f"Welcome back {user_input}.")
  17.             pass_input = input('Please enter password: ')
  18.        
  19.             if pass_input not in choices:
  20.                 incorrect += 1
  21.                 print("Password does not match. Please try again")
  22.             else:
  23.                 run = False
  24.                 print('Access granted')
  25.                 sys.exit()
  26.                
  27.     if incorrect == max_tries:
  28.         sys.exit()        
  29.  
Advertisement
Add Comment
Please, Sign In to add comment