a = 10
class Car():
global a
print a
When I run this code, the value 10
gets printed. Why?
a = 10
class Car():
global a
print a
When I run this code, the value 10
gets printed. Why?
When running a Python program, everything is executed, with the exception of functions. Try putting the code in class Car into a function.