The Python REPL

Try out Python using the REPL – the Read, Evaluate, Print Loop.

Open up a command prompt, or the Terminal app on a Mac and type:

python3

Or you could use an online service such as https://repl.it/

You’ll see something like this:

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Your numbers will certainly be different to what you see above.

That string >>> is your prompt. Type something like this:

1+2

Python will respond with 3 and then give you another prompt. Try this:

hello python

You’ll see this:

File "<stdin>", line 1
hello python
           ^
           SyntaxError: invalid syntax

That’s not very helpful! In simple terms it means we didn’t follow the rules of the language. Head over to The Basics to start learning how to write Python.