The boredless ... project

Hello

destinations = [
    "Paris, France",
    "Shanghai, China",
    "Los Angeles, USA",
    "São Paulo, Brazil",
    "Cairo, Egypt"
]

conosle Error for line 5 for “São Paulo, Brazil”,

SyntaxError non-ASCII character ‘/xc3’ in file …
but not encoding declared see http://python.org/dev/peps/pep-0263/ for details

I have to change it to a to solve .

Hi there, welcome to the forums!

In future, if you’re asking a question about a particular exercise or project, it’s really helpful if you also provide a link to the project in question. (It would have saved me the 10 minutes I spent trying to find it in the Catalog! :slight_smile:)

You’re getting an error because I think you’re running the script with python, which would mean you’re using Python 2. You can verify this by running python --version in the bash terminal in the learning environment, like so:

In Python 2, strings are ASCII by default. If you want to use a non-ASCII character, like ã, you need to tell Python to expect it in some way.

The easiest way to do this is by telling Python what encoding you’re using. On the very first line of your “script.py”, you can copy and paste the following:

# coding: utf-8

Your program will run fine then with the ã character, because we’ve told Python to default to using UTF-8 which includes a codepoint for that character.

In the lesson instructions, though, #26 does say to run python3 script.py.
image

It’s possible you’ve just made a typo, and run python script.py instead of python3 script.py.

Python 3 uses unicode by default, so you wouldn’t get that error. :slight_smile:

1 Like