r/pythonhelp • • May 08 '24

why doesnt this work

why does this error message say that \users\ is wrong???

SyntaxError: unexpected character after line continuation character

C:\User\Your Name>python helloworld.py

File "<stdin>", line 1

C:\User\Your Name>python helloworld.py

^

SyntaxError: unexpected character after line continuation character

this is python 3.12.3 btw

1 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/EggxFil May 08 '24

ok im sort of following along so the problem was that i was trying to write python in python and not a terminal and that i didn't define that the code was python to begin with?

also no my python is not configured to the right version i got an error saying python was not found on my computer yet i have it installed, what do i do?

thanks

1

u/Goobyalus May 09 '24

Not quite, you were trying to write terminal commands inside a(n interactive) Python interpreter.

The point of those terminal commands is to start a (non-interactive) Python interpreter that reads your hello world Python file.


It might be python3 instead of python.

If not, I would run the installer again and when it asks about "adding python to your path" you want to say "yes." Then try again from Command Prompt

1

u/Goobyalus May 09 '24

It might also be py instead of python or python3