Skip to content
Advertisement

The else function does not appear even if the “if” conditions are not met [closed]

The problem is when the bro says “no” the condition “if” always appears even if i use “else” or “elif”, why? Isn’t it supposed that if the input is something other than yes or yeah, is else what appears? pls help

ok here is my code:

JavaScript

enter image description here

Advertisement

Answer

In Python, the expression:

JavaScript

is equivalent to:

JavaScript

And, since "YEAH" is a truthy value, this will always be true. The right way to use or in this case is with:

JavaScript

but you would be better off with the more Pyhtonic:

JavaScript

Make sure you change all three of the problem lines in your code.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement