0
How to explain the first expression?
>>> 3 in [1, 2, 3] == [1, 2, 3] True >>> (3 in [1, 2, 3]) == [1, 2, 3] False >>> 3 in ([1, 2, 3] == [1, 2, 3]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: argument of type 'bool' is not iterable
1 ответ
+ 3
The operator in needs an iterable on the right side.
But [1,2,3] ==[1,2,3] evals to True.
First expression:
[1,2,3] is truthy like all variables that are not empty, None or 0. Convince yourself and use [ ] instead [1,2,3].