Python input not working - 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: Python input not working (/thread-20958.html) |
Python input not working - Vqlk - Sep-08-2019 print("Welcome to project Apollo!") time.sleep(0.5) RegQ = True while RegQ: RegLR = input("Do you want to login or register: ") if RegLR.lower() == "register": print("Please use the register app provided!") time.sleep(3) continue elif RegLR.lower() == "login": print("Welcome to Login manager!") time.sleep(1) break else: print("Unknown input!") time.sleep(2) continue LoginBegin = True while LoginBegin: ForgotPass = input("Have you forgotten your password?: ") if ForgotPass.lower() == "no" or "n": print("Please login:") Username = input("Enter Username: ") Password = input("Enter Password: ") elif ForgotPass.lower() == "yes" or "y": __forgotpass__() else: print("Unknown input!") continueSomehow this code is not working. The do you want to login works but the i get to the Forgotpass input. Whatever I type in the input "Have you forgotten your password?: " It will always : print("Please login:") Username = input("Enter Username: ") Password = input("Enter Password: ") If I type yes it will still do it and if I type a random string it will still do it. Sorry this may be a bit confusing but it is hard to explain. if you need me to explain anything else please tell me. Code for the __forgotpass__: RE: Python input not working - Gribouillis - Sep-08-2019 The table of operator precedence in python shows that == binds terms more tightly than 'or' >>> "a" == "b" or "c" 'c'because "a" == "b" or "c" is the same as ("a" == "b") or "c" , which in turn is the same as False or "c" which value is "c" .In your case, you need if "a" in ("b", "c"): ...
RE: Python input not working - Vqlk - Sep-08-2019 Sorry ima bit confused (new to python) |