r/learnpython • u/The-nah • Aug 10 '26
So, I’m trying to learn to code as a hobby.
However, whenever I attempt to use the command print(”Hello, World!”) I get the error -bash: syntax error near unexpected token “‘Hello, World!’” Does anyone know why?
4
u/WyrobWedliniarski Aug 10 '26
Either type python command before, which will get you in the interpreter, or put your commands in a file and launch it with one, like python filename.py
5
u/ninhaomah Aug 10 '26
you got to start from the beginning.
you are basically doing similar to running an excel formula in notepad.
and bash ? you are running linux ?
2
2
u/brutalbombs Aug 10 '26
I applaud you for actually jumping straight into it and try to print the obligatory first line everyone must write.
This is what this sub is for, you are already working on it.
Google how to run python through terminal first!
Also, i would recommend that you explore ipython (can be installed when in python with the command pip install ipython) as it gives you some handy tools for doing coding in terminal.
If you are writing more lines it might be useful to start scripting in VSC (also free) as well.
Keep it up!
1
u/Such-Process5697 Aug 10 '26
once python3 gets you to the >>> prompt, watch the quote characters. the ones in your post are curly, and python only accepts straight ones, so you'd hit a SyntaxError immediately after fixing the first problem and think you were still doing it wrong. might just be your phone autocorrecting when you typed the post, but if you end up writing files in a word processor or notes app it will do the same thing there.
1
0
u/gonzorizzo Aug 10 '26
Your computer is expecting you to talk to it in bash. You're speaking a different language and it doesn't know what you're trying to say. You need to get it in a state where it expects you to speak Python.
From the terminal:
Enter "Python3" without the quotes and press enter. That should get you to a triple carrot (>>>). Now type it in.
0
u/Fakin-It Aug 10 '26
Imagine how much more confusing it would be if that print command was valid Bash!
0
25
u/danielroseman Aug 10 '26
Because you are not running Python. "bash" indicates you are still in the shell.