def add_this_many(x, el, lst):
""" takes in a value x, a value el,
and a list and adds as many el’s to
the end of the list as there are x’s"""
if x == 0:
return lst
else:
tmp = lst.append(el)
return add_this_many(x-1,el,tmp)
lst = [1,2,3,4,5]
add_this_many(1,5,lst)
您能告诉我为什么此递归调用不附加列表吗?它只是将tmp分配为None!列表是否有些特殊?