Python Forum

Full Version: Keeps looping even after correct answer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I cant get this to stop looping even after correct answer. Any help would be greatly appreciated.
# Administrator accounts list
adminList = [
    {
        "username": "DaBigBoss",
        "password": "DaBest"
    },
    {
        "username": "root",
        "password": "toor"
    }
]

# Build your login functions below
def getCreds():
    username = input("What is your username? ")
    password = input("What is your password? ")

    return {"username": username, "password": password}

def checkLogin(adminList, user_info):
    if user_info in adminList:
        getCreds = True
        print("YOU HAVE LOGGED IN!")
    else:
        getCreds = False
        print("----------")
        print("Login Failed")
        print("----------")
        retry = getCreds
        return

while True:
    user_info = getCreds()
    is_admin = checkLogin(adminList, user_info)
    print("----------")
    if is_admin:
        print("YOU HAVE LOGGED IN!")
        break
your checkLogin function will ALWAYS return None.
None is evaluated as False (on line 36) so you never break
Thank you for your help!