the code:
class ceshi():
def one(self):
global a
a = "i m a"
def two(self):
print(a)
if __name__ == '__main__':
ceshi().two()
error message: NameError: name 'a' is not defined
Didn't I define "a"? why the error message is 'name "a" is not defind'
a = somethingwill be defininga. Since you want it to be global it should be outside the class scope.aisn't out of the class. You can perfectly leave it withindef one()and be global, but you also need to actually make a call to functionone(), which you never do.