0

If statement syntax error

So my code lookes like this, If 1 >= 1 print(1) And i get a syntax error on line 1, with an arrow pointing to the spot directly after 1. But there is no space. And if instead of >= i have = its instead going to have a syntax pointing to the =. Why is this?

21st Jan 2025, 2:58 AM
GachaWolf810
GachaWolf810 - avatar
5 odpowiedzi
+ 5
GachaWolf810 put a colon(':') after the if statement. if day < 7: ... also use == for comparison, = is for assignment.
21st Jan 2025, 4:01 AM
Bob_Li
Bob_Li - avatar
+ 2
GachaWolf810 regarding the error when replacing >= with just =, That is a one of the most common errors in programming. A single = is the assignment operator. You wanted == which is equality comparison operator.
21st Jan 2025, 4:49 AM
Shardis Wolfe
+ 1
Thanks!!!!
21st Jan 2025, 4:36 AM
GachaWolf810
GachaWolf810 - avatar
+ 1
Thanks to you both! Bob_Li and Shardis Wolfe
21st Jan 2025, 5:07 AM
GachaWolf810
GachaWolf810 - avatar
0
Also this code, #use numbers 1-7 to represent days of the week day = int(input()) if day < 7 print("Dammit! its not sunday yet >:(") if day = 7 print("Yay! lets get ready!") if day > 7 print("thats not a valid day of the week...") Provides the same type of syntax error after the 7 on line 4
21st Jan 2025, 3:47 AM
GachaWolf810
GachaWolf810 - avatar