Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python input not working
#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
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__:
Reply
#2
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"): ...
Reply
#3
Sorry ima bit confused (new to python)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,497 Apr-05-2022, 06:18 AM
Last Post: C0D3R
  Python input not working Mar10 4 13,835 Mar-17-2021, 11:21 AM
Last Post: snippsat
  Input() function not working in VS Code darpInd 7 13,359 Feb-17-2020, 03:28 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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