Booleans | SoloLearn: Learn to code for FREE!

0

Booleans

print(1 == 1 and 2 == 2) print(2 == 2 or 3 == 4) print(2 < 1 not 3 > 6) File "..\Playground\", line 7 print(2 < 1 not 3 > 6) ^ SyntaxError: invalid syntax Why do I get an error?

11/18/2018 9:30:35 PM

Pauline

2 Answers

New Answer

+6

You can't use the 'not' operator to chain two conditions, which is why you have two different conditions in the third if-statement, which is not valid. 'not' is used to reverse one condition, however, if you want to chain two or more conditions, use 'and' or 'or' as you did in the first two statements.

+1

Because not operate on single operand not two.