Only today I put Python and began to study. Posted in IDLE:

>>>print("hello world") 

IDLE returned, everything is super. Saved to 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?

  • win10, python 3.7 on another machine the same parsley. - Stefan Voronikov
  • error in syntax - add a copy of the file contents - Eugene Dennis
  • print ("hello world") - Stefan Voronikov

2 answers 2

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

Pass each line and on each of it press the End key on the keyboard.

Then delete unnecessary characters, save the file and write again.

 python hw.py 
  • Many thanks for the advice. I'm already at home and on my home PC trying to do the same. In the code one line. There can be no characters. (This is the third car today, on which I put the Python). Actually, I only dealt with JS before. Maybe I'm doing something wrong - now I just dialed the code in Atom and saved it with the extension .py - I can not imagine what was the matter. And do not forget that the console perfectly returns the result. Maybe it's in the path to the file, there are also slashes? - Stefan Voronikov
  • The paths to the file are recorded depending on the operating system (Windows, Linux, ...), best of all with / and in quotes when there are spaces in them. I have all the problems without problems, with or without paths. It is possible that you have 2 hw.py files (in different folders) and you are editing one, but running the other? Try writing your program directly to IDLE (as a new file) and then launching it with the F5 key - IDLE will want to save your program in a file, write a name for it and then try working with this file. - MarianD

The encoding is worth checking, it should be utf-8, I have such a thing if the file in cp1251 is saved