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”?

9th Mar 2019, 2:05 AM
Sergio Chan
Sergio Chan - avatar
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
9th Mar 2019, 4:12 AM
Tibor Santa
Tibor Santa - avatar