Keeps looping even after correct answer - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Keeps looping even after correct answer (/thread-23131.html) |
Keeps looping even after correct answer - mcesmcsc - Dec-12-2019 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 RE: Keeps looping even after correct answer - buran - Dec-12-2019 your checkLogin function will ALWAYS return None .None is evaluated as False (on line 36) so you never break
RE: Keeps looping even after correct answer - mcesmcsc - Dec-12-2019 Thank you for your help! |