What mistake did I made here? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What mistake did I made here?

I'm trying to make an yes or no question and giving out also with using only if statement. Please don't laugh coz I'm a beginner in python programming 😅. I don't know what did I miss. I want to know how to complete this using only if statement. Teach me please đŸ€”..Help me guys!!! Input is here x = input("bro do you love me?: ") x = str(x) if x == yes: print('love you too') if x == no: print('kill you') Output is here đŸ€Ż bro do you love me?: yes Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 3, in <module> NameError: name 'yes' is not defined [Program finished]

30th Sep 2020, 5:20 PM
Manas Biswal
Manas Biswal - avatar
3 Answers
+ 6
yes and no needs to be in quotes like "yes" , "no" the second line of your code can be removed, as input returns always strings a conversion is not needed. You could improve your coding skills by working through the python tutorial.
30th Sep 2020, 5:24 PM
Lothar
Lothar - avatar
+ 3
if x == “yes” and if x == “no”
30th Sep 2020, 7:04 PM
D.M.
D.M. - avatar
+ 1
" ", ' '!!!!!!!!!
30th Sep 2020, 7:57 PM
Shadoff
Shadoff - avatar