0
Why wint this work
#just something simple print("hello yow are you") #type either bad,good,ok,sad or angry input("you are feeling") if input=="bad": print("why are you feeling bad") if input=="good": print("im glad to hear that") "" if input=="ok": print("nice") if input=="sad": print("thats sad to hear") if input=="angry": print("calm down")
3 Answers
+ 3
You are calling input but you are not storing the result in any variable. In order to check for the content of the response, you must assign it to a variable like this:
resp = input("you are feeling")
Now you can access the user input via resp.
if resp == "bad":
etc...
You might also want to use elif (else if) instead of if every time to simplify everything.
The whole code (fixed) should look like this:
print("hello, how are you")
resp = input("you are feeling")
if resp == "bad":
print("why are you feeling bad")
elif resp == "good":
print("im glad to hear that")
elif resp == "ok":
print("nice")
elif resp == "sad":
print("thats sad to hear")
elif resp == "angry":
print("calm down")
# else is used when nothing of the above is matched
else:
print("i dont understand your emotions")
+ 1
In your if condition you would have used input() instead of input. The function needs be called. However this style is strictly not recommended.
0
thanks