You are typing Python code in System terminal(zsh). If you are trying to recall the code line by line you need to do it in Python interactive terminal. Type python and seeing >>>on the terminal starting point you are good to go.
python
>>>