Carlos_s
Carlos_s

Reputation: 11

If statements running at the same time how to

if input("Raining? ") == "yes":
    print("Then you should take an umbrella")

if input("Raining? ") == "no":
    print("Then you should not take an umbrella ")

so I want these 2 to check yes or no at the same time so when I type no the printed answer should be "Then you should not take an umbrella" but the thing is it asks twice when I say no example:

Raining? no
Raining? no
Then you should not take an umbrella

any ideas how I can make this work ?

I just want to ask you Raining? no and the answer to be Then you should not take an umbrella, not asking you twice and the second time works

Upvotes: 0

Views: 121

Answers (2)

Eli Harold
Eli Harold

Reputation: 2301

Just save the input to be compared later.

inp = input("Raining? ")
if inp == "yes":
    print("Then you should take an umbrella")
elif inp == "no":
    print("Then you should not take an umbrella ")

Upvotes: 0

Cameron
Cameron

Reputation: 377

Ask for the input before the if statement.

For example:

value = input("Raining? ")
if value == "yes":
    print("Then you should take an umbrella")
elif value == "no":
    print("Then you should not take an umbrella")

Upvotes: 4

Related Questions