Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Administrator accounts list
- adminList = [
- {
- "username": "DaBigBoss",
- "password": "DaBest"
- },
- {
- "username": "root",
- "password": "toor"
- }
- ]
- # Build your login functions below
- def checkLogin(userInfo, adminList):
- #look through adminList for a match with userInfo
- for user in adminList:
- #if userInfo matches current user
- if user['username'] == userInfo['username'] and user['password'] == userInfo['password']:
- return True
- return False
- def getCreds():
- #ask for username and password
- username = input("enter username: ")
- password = input("enter password: ")
- return {"username": username, "password": password}
- loggedin = False
- #while the user is not logged in (logged in is false
- while loggedin == False:
- #save the credentials
- userInfo = getCreds()
- #check and save the credentials in loggedin
- loggedin = checkLogin(userInfo, adminList)
- print("---------")
- #if credentials is false
- if loggedin == False
- #tell user to try again
- print("wrong try again! ")
- #you logged in yayayay
- print("YOU HAVE LOGGED IN!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement