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 Answer
+ 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