r/code • u/TheSwanSennin • Nov 03 '23
Help Please Why does this code only generate a smiley face?
Additional info:
- This is Python.
- I know the frowny function draws a frown.
- I've already looked this up but anything I can find is too general.
- I've contacted my instructor but she won't respond until Monday or later most likely.
- The user function part works, but no matter what I put it draws a smiley face.
5
Upvotes
8
u/mfar__ Nov 03 '23
When you say
The interpreter reads it as
And the boolean value of any non-empty string is True, so the first condition is always true and the interpreter will not look at other conditions.
What you want to do is:
Or
Or you can simply do this:
Of course this is applied to 'No' and 'no'.
1
u/EunseokOh Nov 04 '23
You can simply make that in code.org by making a animation and just make a function frowny to display the frowns face and the function should be: frowns.visible==true Of course, you need a variable to display the animation and this is gamelab. Just prompt what you want with variable attached and just do If variable == "no" || "No" { frowny() }
1
u/Dull_Investigator985 Nov 03 '23
shpuld the colons be there ?