Python Forum

Full Version: Python input not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!")
        continue
Somehow 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__:
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"): ...
Sorry ima bit confused (new to python)