dennoh

Login User

Jan 21st, 2021
962
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def login():
  2.     print("Login")
  3.     username = input("Username: ")
  4.     password = input("Password: ")
  5.     if user_exists(username, password):
  6.         print(f"Welcome {username}")
  7.     else:
  8.         print("Invalid User")
  9.  
  10.  
  11. def user_exists(username, password):
  12.     with open('user.txt') as f:
  13.         users = f.readlines()
  14.         exists = False
  15.  
  16.         for user in users:
  17.             if username in user:
  18.                 exists = True
  19.                 break
  20.         return exists
  21.  
  22.  
  23. if __name__ == "__main__":
  24.     login()
RAW Paste Data