Writing our First Python Code

Running Python 3 as a Default (on macOS)

In this course, we will use Python 3.x. Try running python3 instead of python in case you're using an older version by default (see below for additional information).

You can see the version of Python that's being used for the REPL (command line) or to execute your files when running python --version . 

If this says Python 2.7 (or anything else but some version starting with 3 - e.g. 3.5), you can run Python 3.x by executing python3 instead of just python .

This is especially important on macOS, where you already got Python 2.7 pre-installed. To NOT use that, run python3 instead of python .

Alternatively, you change the Python version used by default as discussed and described in this thread: https://stackoverflow.com/questions/18425379/how-to-set-pythons-default-version-to-3-3-on-os-x

You essentially can run these two commands to change the default version being used:

unlink /usr/local/bin/python
ln -s /usr/local/bin/python3.6 /usr/local/bin/python

Thereafter, you can just run python to use Python 3.x