1

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 :)

1

2 Answers 2

5

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
Sign up to request clarification or add additional context in comments.

Comments

2

"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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.