class A:
x=10
def fn(self):
print(x)
I tried running this code, but an error comes out as:
NameError: name 'x' is not defined
inside the function block if i put self.x then it works perfectly my doubt is why doesnt the above code work properly x is defined in class scope,so shouldnt it be accessable to all functions defined in class as class_variable also