Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
inputs and if statements
#1
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
The input Forgotpass Always the if ForgotPass.lower() == "no" or "n": no matter what I type. Should I remove the equals sign or do I have to use an if staement for every single output.
Reply
#2
Replace ForgotPass.lower() == "no" or "n": with ForgotPass.lower() in ("no", "n"):.
Because the former equals (ForgotPass.lower() == "no") or "n", and "n" is always True.
Reply
#3
would that work with an if statement
Reply
#4
(Sep-08-2019, 01:26 PM)Vqlk Wrote: would that work with an if statement
Replace if ForgotPass.lower() == "no" or "n": with if ForgotPass.lower() in ("no", "n"): or if ForgotPass.lower() == "no" or ForgotPass.lower() == "n".
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020