Is it possible in python3 to declare a function inside a nested function? how many levels can I get in ?how to call the display() function?
def calculator():
def add():
def display():
Is it possible in python3 to declare a function inside a nested function? how many levels can I get in ?how to call the display() function?
def calculator():
def add():
def display():
Yes, it's certainly possible. As others have said, you'll be limited to 20 levels.
Be careful, though, because a nested function can only be called from the scope it's defined in.
It's also possible to get easily confused with nesting that deep (you may not actually be invoking the inner function like you expect). You can see a working example at: