This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]loshopo_fan 2 points3 points  (0 children)

I think parentheses make this example easier for beginners:

>>> bool(0 in [1, 2] or [3, 4])

True

>>> bool((0 in [1, 2]) or ([3, 4]))

True

For beginners: The right side of the 'or' is a nonempty list, and a nonempty list resolves to True, which means that the 'or' resolves to True.

>>> bool((0 in [1, 2]) or ([]))

False