-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
This line doesn't do what you think it does. It is parsed like this:
if ('test' == 'nada') or 'nothing':
print('ok')
else:
print('nope')Which will always execute, because even though 'test' != 'nada', 'nothing' is truthy because of bool(non-empty-str). It's the same as if False or True:.
The better way would be:
if 'test' in ('nada', 'nothing'):
print('ok')I rewrote this for Python 3, using a dict-style instead of if-else, and reformatted the output.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels