Advertisement
dennoh

Login User

Jan 21st, 2021
1,230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement