Why does my code get a <stdin> syntax error?

Hello there,
So, a bit of history first. I have taken the magic 8 ball challenge to my workspace in python, and have been trying to add more functionality to it, by adding classes, more responses, implementing a while loop etc.
But now, when I attempt to run the code I get a syntax error on line 1.
The code ran fine before I started to restructure it, but I cannot figure out why it throws up this particular error.

The code still runs the first few lines of generating a random number and printing it to the console, but with the error referring to line 1, it seems to just be wrong…
Google says the most common occurrence of this error message is when the script is attempted to be opened inside of the command line running the script.
I’ve asked the Codecademy help and they have been fairly unhelpful, and told me to come here. I assumed i had just missed a colon or some syntax, but as far as I can see they’re all there. Again, this code worked before its restructure and a simple bug test has had me reeling for days trying to fix it!
is the workspace doing something it shouldn’t, or am I just being a daft silly billy with an obvious solution staring at me?

You want to run the script directly in the shell, not in an existing interactive python session. So instead of running-

$ python3
>>>  python3 script.py

You’d want instead-

$ python3 script.py

If you see the triple arrows on the right hand side then make sure to exit that Python session before trying to run the whole script at once.


python3 command is an environment variable that is understood only by your system. It takes the file you enter after it and runs it through the interpreter. So if you run in inside the >> prompt, the python interpreter does not know what python3 means and throws an error. You can use the command:
python3 filename.py from within your Terminal/Command Prompt.

If that is the explanation, why does it run the randint number and print it, but not the remainder of the code?