How to Print Hello World in Python

Print Hello World in Python in the interactive shell and from a file, and fix the most common error beginners hit.

Python's Hello World is one line. Here is how to run it two ways.

Check that Python is installed

Open a terminal (Terminal on Mac, Command Prompt on Windows) and run:

python3 --version

You should see something like Python 3.12.4. On Windows the command is usually python instead of python3. If neither works, install it from python.org.

Run it in the interactive shell

Type python3 and press Enter. The prompt changes to >>>. Now type:

print("Hello, World!")

Press Enter and the text prints on the next line. Type exit() to leave the shell.

Run it from a file

Create a file called hello.py containing:

print("Hello, World!")

Save it, then run it from the same folder:

python3 hello.py

The output is identical. Files are how you will run every real program, so this is the one to remember.

The most common error. If you see SyntaxError: Missing parentheses in call to 'print', you are running Python 2 syntax on Python 3. print needs parentheses in Python 3, exactly as written above.

More Coding how-tos