I wish to ask that I want to take data and data2 from number() and transfer it to take() in which I can use it to print at the main method
def number():
global data
data=1
global data2
data2=2
def take():
global finalAns
finalAns=data+data2
print(finalAns)
After writing the code, the error I obtained is
NameError: name 'finalAns' is not defined
Why is this so? I thought that all variable that has a global attribute can be passed to other methods.