Or Command In If Statement Not Working Properly
In the code below, the if statement is triggering no matter the condition satisfies or not. the problem is with 'or' or anything else i do not know. please help while True: q = in
Solution 1:
You need to use it like this:
if'a'in q or 'b'in q:
...
It is necessary to check for every variable if it is in q
.
Clause under if
:
if'a':
will always be executed, because it is "truthy". Python considers string "truthy" if it is not an empty string.
"falsy" are empty strings, 0 integer, empty arrays and empty dicts.
Post a Comment for "Or Command In If Statement Not Working Properly"