Reputation: 1
Example
Good=1
Bad=2
print("How was your day?")
input()
if Good:
Print("That's nice.")
elif Bad:
Print("That's unfortunate")
For some reason this program always respond with "That's nice." even when I say bad.
Upvotes: 0
Views: 50
Reputation: 2946
You didn't assign the input value to a variable.Try the following code:
Good = 1
Bad = 2
print('How was your day?')
inputVal = int(input())
if inputVal == Good:
print("That's nice.")
elif inputVal == Bad:
print("That's unfortunate")
Input:1
Output:That's nice.
Input:2
Output:That's unfortunate
Upvotes: 0
Reputation: 1968
if Good
is always True
, you have to assign input to a variable and then compare:
inp = input()
if inp == Good:
...
Upvotes: 1
Reputation: 2935
You aquired the input value, but did not assign it to a variable.
You should introduce a new variable (let's call it answer
):
good=1
bad=2
print("How was your day?")
answer = input() ## <-- changed
if answer == good: ## <-- changed
print("That's nice.")
elif answer == bad: ## <-- changed
print("That's unfortunate")
Upvotes: 0