Help me with my code

Question = ""

print("What would you like?")

if Question == "Log out":
    print("Logged out. Please close the page.")

else:
    print("Goodbye")
        
input("\n\nPress enter key to exit")

I want my code (when it is running) to ask me what I want and it does that, but it goes straight to ‘Press enter key to exit’ and I don’t get a chance to answer.
How do I make the code the code ask me what I want and let me reply.
Thanks for any help!!!:relaxed:
PS I will create more questions that I can ask.

The only input you’re asking for is on the last line, so there’s no way to change the Question variable.

Reassign the value of your variable to user input with a question something like your first print() call (replace it).

1 Like

Thank you for the advice I tried it and it worked. Thanks again!

Now it let’s me do a reply, but if I write ‘log out’ after it asks me what I want it always says ‘Goodbye’. Any advice on that?

This isn’t compared. You need to use correct capitalisation.

I use correct capitalisation (as shown below) yet it still says Goodbye.

What it comes out with:

What would you like?Log out
Goodbye

Press enter key to exit

Thanks for any advice.

Could you post the whole code?

This is the whole code:

security = 0

username = ""
while not username:
    username = input("Username: ")

password = ""
while not password:
    password = input("Password: ")

if username == "Mia R" and password == "I'm awesome":
    print("Welcome Master!")
    security = 100

elif username == "Harriet R" and password == "Harriet3106":
    print ("Welcome Harriet.")
    security = 50

elif username == "Annabel R" and password == "Jane3170":
    print ("How are you doing Annabel?")
    security = 50

elif username == "Jane R" and password == "Annabel":
    print("Good day Mummy.")
    security = 50

elif username == "Jonathan R" and password == "Annabel02":
    print("Hello daddy!")
    security = 50

elif username == "guest" and password == "guest":
    print("Welcome guest.")
    security = 1

else:
    print("Login failed. You're not so exclusive are you.\n")

print("security level = ")
print(security)

if security>=1:
    
    Question = ""
    NO1 = ""
    NO2 = ""
    
    while not Question:
        Question = input("What would you like?")

    if Question == "Log out":
        print("Logged out. Please close the page.")

    elif Question == "Please call someone":
        int(input("Please enter the number"))

    elif Question == "Please email someone":
        input("Please enter email adress")
        
elif security>=50:
    
    Question = ""
    NO1 = ""
    NO2 = ""
    
    while not Question:
        Question = input("What would you like?")
        
    if Question == "Please add two numbers":
        while not NO1:
            NO1 = int(input("Please enter first number"))
        while not NO2:
            NO2 = int(input("Please enter second number"))
        print("The sum of the numbers is ")
        print(NO1+NO2)

    elif Question == "Please multiply two numbers":
        while not NO1:
            NO1 = int(input("Please enter first number"))
        while not NO2:
            NO2 = int(input("Please enter second number"))
        print("The product of the numbers is ")
        print(NO1*NO2)
        
if security>=100:
    
    Question = ""
    NO1 = ""
    NO2 = ""

    while not Question:
        Question = input("What would you like?")
        
    if Question == "Please subtract two numbers":
        while not NO1:
            NO1 = int(input("Please enter first number"))
        while not NO2:
            NO2 = int(input("Please enter second number"))
        print("The difference of the numbers is ")
        print(NO1-NO2)

    elif Question == "Please divide two numbers":
        while not NO1:
            NO1 = int(input("Please enter first number"))
        while not NO2:
            NO2 = int(input("Please enter second number"))
        print("The answer to the question is ")
        print(NO1/NO2)

    else:
        print("Goodbye") 
        
input("\n\nPress enter key to exit")

I have fixed the problem I had before. I have another problem though. My code is supposed to stop people who have a lower security cannot ask as many questions. I tried as Jane R, it asked me what I wanted, but when I asked it to add two numbers it went straight to ‘Press the enter key to exit’ even though it should of asked me what my first number was.