Reputation: 23
I have this Syntax Error in IDLE:
SyntaxError: can't assign to operator
This then highlights the end of a line, line 2 of the following code:
date = "Unknown"
day-of-week = "Unknown"
time = "Unknown"
week = "Unknown"
I would appreciate any help I can get with this :)
Upvotes: 1
Views: 292
Reputation: 911
Python is interpreting day-of-week
as "day" minus "of" minus "week". Try using day_of_week
instead.
Sample code to show this.
>>> day = 3
>>> of = 2
>>> week = 4
>>> day-of-week
-3
Upvotes: 5
Reputation: 3077
"Day-of-week" is an invalid variable name, and you can't use the minus sign on the left side of an assignment operation.
Your code is the equivalent of:
day - of - week = "unknown"
Try
day_of_week = "unknown"
Instead!
Upvotes: 2