'how do I print the inner_inner_func_2 in case without changing the code?
def outer_function(): # this is the outer most function
print("I am outer")
def inner_func(): # inner function
print("I am inner")
def inner_inner_func(): # inside the inner function
print("I m inner inner")
def inner_inner_func_2(): #inside the child of inner child
print("I a inner inner 2")
return inner_inner_func_2
return inner_inner_func
return inner_func
a = outer_function()
Solution 1:[1]
inner functions don't return anything at all;
because of it, you don't need to use the return command.
you can just call them with this code:inner_func_2()
but if your code is something else and bigger that returns something; please edit and fix your question.
Solution 2:[2]
There is an formatting mistake in the question, the outer_function
was not included.
def outer_function():
def inner_func(): # inner function
print("I am inner")
def inner_inner_func(): # inside the inner fucntion
print("I m inner inner")
def inner_inner_func_2(): #inside the child of inner child
print("I a inner inner 2")
return inner_inner_func_2
return inner_inner_func
return inner_func
outer_function()()()()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | BGOPC |
Solution 2 | cards |