0
“not False” is still ”False”?!
x = [0, 0, 0] y = [1, 1, 1] b = x and y print(not b) So far I know that “x and y” is “False” because they have different elements. So why “print(not False)” is still “False” rather than “True”?
1 Respuesta
+ 4
Check also what is the result of
print(b)
It actually results in the second list (y)
You cannot compare lists like this. The 'and' operator evaluates both operands and they are both true (because a non-empty list is considered True by python) and the last operand is returned.
So 'not b' is negating the True value of the result (the non-empty list).
I hope that makes sense.
Look also here:
https://stackoverflow.com/questions/47419342/logical-operation-between-two-boolean-lists/47419399