I have 2 scenarios where the verdict results into a runtime error, but with 2 different messages:
Scenario 1:
def a():
print(aa+bb)
#aa=10
#bb=20
print(a())
Verdict for Scenario 1:
Traceback (most recent call last):
File "Solution.py", line 6, in <module>
print(a())
File "Solution.py", line 2, in a
print(aa+bb)
NameError: name 'aa' is not defined
Scenario 2:
def a():
print(aa+bb)
aa=10
bb=20
print(a())
Verdict for Scenario 2:
Traceback (most recent call last):
File "Solution.py", line 6, in <module>
print(a())
File "Solution.py", line 2, in a
print(aa+bb)
UnboundLocalError: local variable 'aa' referenced before assignment
Now, if the interpreter executes the code line by line and immediately halted after it encountered an error on line 2, how did it generated 2 different error messages.