Reputation: 11
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
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
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