I'm still in the process of learning python and there is a problem that I am not able to understand.
def demo():
  print(a)
  a += 5
a = 100
print(a)
demo()
print(a)
If i run this program it gives a traceback error which is obvious. But the problem comes when I run the below code.
def demo():
  print(a)
a = 100
print(a)
demo()
print(a)
If I remove the a += 5 line then the program runs just fine and produce the output -
100
100
100
My question is that it should still give traceback error because I still have not yet defined what a is in the function body and neither did I give a as argument. But it doesn't give the error. Can anyone  please explain it to me why it is ?
 
     
    