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?
5 odpowiedzi
+ 5
GachaWolf810
put a colon(':') after the if statement.
if day < 7:
...
also use == for comparison, = is for assignment.
+ 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.
+ 1
Thanks!!!!
+ 1
Thanks to you both!
Bob_Li and Shardis Wolfe
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