Python Forum
If Else Statement with User Input - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: If Else Statement with User Input (/thread-21219.html)



If Else Statement with User Input - CalPark16 - Sep-19-2019

Hello all.

I have an assignment in Python where I need to ask the user whether they are happy or unhappy. The program will then draw a smiley face or a frowny face depending on the user's answer. I can easily use If else statements when the user's input is an integer, but I don't know how to do it if the user's answer is a word like Happy/Unhappy. Here's my code for the if else statement part (I know this is python 3. something, either 3.6 or 3.7):

question = input("Are you feeling happy or unhappy?: ")

if question == happy:
smiley_face()
else:
frowny_face()


RE: If Else Statement with User Input - Axel_Erfurt - Sep-19-2019

try

if question == "happy":