So far, I have understood that Python is an interpreted language so that the interpreter reads and executes instructions, one line at a time, and if it encouters an error, it stops execution and throws an exception. In other words, the execution goes on until an error occours and stops it but previous instructions have been executed. I saw that this behavior changes when there is a SyntaxError. Try this:
import random
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
print(random.randint(1,100))
l = [
The last line causes a SyntaxError. In this case no previous line of code is executed (no print in the console) and this pushed me to think that there can be a preliminary syntax check of the entire source code before execution starts. Could it be the reason of this behavior?