我有一个非常简单的函数,它不使用sum
函数或循环技术来汇总列表元素。这是:
def find_sum(mylist):
def get_value(sublist, counter):
counter += sublist.pop()
if sublist:
get_value(sublist, counter)
else:
print counter # It will print correct result
return counter
my_sum = get_value(mylist, 0) # But my_sum is None
return my_sum
为什么emdedded函数返回None?