Booleans | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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?

18th Nov 2018, 9:30 PM
Pauline
Pauline - avatar
2 Antworten
+ 7
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.
18th Nov 2018, 9:38 PM
Shadow
Shadow - avatar
+ 1
Because not operate on single operand not two.
14th Sep 2019, 6:59 PM
Gourav Saini
Gourav Saini - avatar