Python 2: SyntaxError: Non-ASCII character '\xe2' in file

Dear support community:

I’ve recently (almost) completed the “Command Line Calendar” exercise in Python. When I run the program in the terminal it fails and gives me the following reason:

$ python
File “”, line 1
SyntaxError: Non-ASCII character ‘\xe2’ in file on line 1, but no encoding declared; see PEP 263 – Defining Python Source Code Encodings | for details

What does this mean? What should I do to make the program work? I’m in the deep end!

Here’s a link to the exercise:

Thank you.

The error means python has found a character in your code that it doesn’t recognise. A bit of googling suggests it could be a - (possibly arriving via copy/pasting from elsewhere).
Deleting it/them and re-typing should fix it.

Hope that helps

1 Like