def f1():
X = 88
def f2():
print(X)
return f2
action = f1()
action()
Since f1 is returning f2 so it seems fine when I call f2 as (f1())().
But when I call f2 directly as f2(), it gives error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'f2' is not defined
Can someone explain what is the difference between the function calling of f2 using above 2 ways.