The book is intended/using Python3 while you run the code using Python2.
In Python2
In Python2
Most probably you have both version of python installed, but if not I would recommend to install Python3. Use Python3 (especially given that you are new to Python). usually, if both versions are installed you can invoke Python3 by using
In Python2
raw_input()
takes user input and returns str
, in Python3 that is input()
In Python2
input()
takes input from user and try to evaluate it as code, in Python3 that is eval(input())
Most probably you have both version of python installed, but if not I would recommend to install Python3. Use Python3 (especially given that you are new to Python). usually, if both versions are installed you can invoke Python3 by using
python3 yourscript.py
, not python yourscript.py