+ 2
Why wonât these if and else statements work???
https://code.sololearn.com/c40w825EgmNs/?ref=app Run this code and type a question that starts with âcanâ or âwillâ (eg.can cats fly?). The code should respond with a yes or no answer...but it doesnât?!? The else statement also wonât run!?! https://code.sololearn.com/c40w825EgmNs/?ref=app
5 RĂ©ponses
+ 5
It works if you change your code to this:
if (pick == 1):
print ("yes")
elif (pick == 2):
print ("no")
elif (pick == 3):
print ("obviously!")
elif (pick == 4):
print ("don't think so...")
elif (pick == 5):
print ("maybe, I'm not really sure...")
+ 4
Thanks Xan
+ 2
Didnât realise I had forgotten to change the if statement when I copied and pasted
+ 1
Easily done âș
0
So simple and for some reason entertaining, haha.
Because python is case-sensitive though, any inputs beginning in a capital letter does not run the code as they are not listen in the if-statement!