I just started to learn Python, and I was told that Python code gets executed line by line from the top. So that means if I have an error on line 2, the print method on line 1 should get executed, right? But sometimes it gets executed and sometimes it doesn't. I am really confused. Can somebody please help?
Example 1:
print("Python")
pint("Programming")
Output: Line 1 gets executed but line 2 doesn't because I have written pint instead of print. (As expected.)
In this case, the Python code is executed line by line.
Example 2:
print("Python")
print"Programming")
Output: Error on line 2 without executing line 1. (Unexpected)
Why Python code is not executed line by line in the above example?