The terminal you are trying to run this on probably uses Python 2.x as standard.
Try using the command “Python3” specifically in the terminal:
$ Python3 yourfile.py
(Tested and confirmed that 2.7 will give that error and that Python3 handles it just fine.)