Home python SyntaxError: unexpected character after line continuation character in “Hello World” program

SyntaxError: unexpected character after line continuation character in “Hello World” program

Author

Date

Category

Just today I installed Python and started studying. Wrote in IDLE:

& gt; & gt; & gt; print ("hello world")

IDLE returned, everything is super. Saved in hw.py, the interpreter does not run the file and swears like this

“SyntaxError: unexpected character after line continuation character”

What does he want from me?


Answer 1, authority 100%

In your hw.py file, somewhere in the line you have a \ symbol and something else behind it – you don’t see it, because it is somewhere behind the right edge of the window.

Go through each line and on each of it press the End key on your keyboard.

Then delete unnecessary characters, save the file and write again

python hw.py

Answer 2

The encoding is worth checking, it should be utf-8, I had this if the file is saved in cp1251

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions