I have a class object with a method function. Inside this method function "animal", I have an inner function that I want to call. But it appears that my inner function isn't being called because the correct result should return "hit here" instead of "sample text".
Here is my class code:
class PandaClass(object):
def __init__(self, max_figure):
self.tree = {}
self.max_figure = max_figure
def animal(self, list_sample, figure):
def inner_function():
if len(list_sample) == 0:
return "hit here"
inner_function()
return "sample text"
I instantiate the class and call the animal function with code below:
panda = PandaClass(max_figure=7)
panda.animal(list_sample=[], figure=0)
I want the code to return "hit here" which would mean the inner function got run but instead I got "sample text". Please let me know how I can correct this.
inner_function()if it is not None? A one-liner would look like thisreturn inner_function() or "sample text"or you could save the result and have an if/else