When the user write more than one statements in a shell then he can encounter the error’
“SyntaxError: Multiple statements found while compiling a single statement.”
The reason behind this error that you can not execute more than one statement in a shell.
Look at the following example to understand this error;
>>> print (“My first python code”)
print(“Easier than expected”)
SyntaxError: multiple statements found while compiling a single statement.
What is the syntax error?
A syntax error is an error that occurs that there is something wrong with the code format.
To solve this error you have to write a single statement at a time in a shell. The user needs to execute one by one like;
>>> print(“My first python code”)
My first python code
>>> print(“Easier than expected”)
Easier than expected.
When you see multiple statements are being declared, that means you are seeing a script which will be executed later. But in the interactive interpreter, you cannot do more than one statement at one time.
To open the python shell from IDLE go to File > New File. Type your statements into the shell and save it. The user can name it whatever he wants but make sure that it has .py extension at the end. The from the same shell windows go Run > Run module. Now you can see results.