Guest User

Untitled

a guest
Mar 8th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. """
  2. Program Name: simpleLogin.py
  3. Created By: Majin Goten
  4. Program Description:
  5.    Simple login to a simple database of simpleness
  6. """
  7. def main(): # Main Program
  8.     userName = "JohnDoe123" # Change this to any username
  9.     passWord = "password123" # Change this to any password
  10.     while True: # Loops until correct username entered
  11.         nameEntered = input("Username: ") # Asks for username from user
  12.         try: # Executes code inside successfully, if no errors found
  13.             # Compares user input with actual username
  14.             if nameEntered.lower() == userName.lower():
  15.                 # Exits loop if username is correct
  16.                 break
  17.             else:
  18.                 # Prints error message if wrong username
  19.                 print("\nSorry", nameEntered,"does not exist in the database!\n")
  20.         except:
  21.             # Print error message if the above code fails
  22.             print("\nInvalid Input, try again!\n")
  23.     # Tell user to enter password
  24.     print("\nEnter the password for",nameEntered,"below")
  25.     while True: # Loops until correct password entered
  26.         passEntered = input("Password: ") # Asks for password from user
  27.         try: # Executes code inside successfully, if no errors found
  28.             # Compares user input with actual password
  29.             if passEntered.lower() == passWord.lower():
  30.                 # Exits loop if password is correct
  31.                 break
  32.             else:
  33.                 # Prints error message if wrong password
  34.                 print("\nSorry, incorrect password, please try again!\n")
  35.         except:
  36.             # Prints error message if the above code fails
  37.             print("\nInvalid Input, try again!\n")
  38.     print("Welcome",userName+"!") # Prints welcome message
  39.  
  40. main() # Call to main()
Add Comment
Please, Sign In to add comment