I'm practicing for an exam and trying to figure this out. I'm just not exactly what to do with the add method. This is what I have so far:
class recursion:
def __init__(self, lst=[]):
self.lst = lst
def add(self, x, y):
return x + y
def recurs(self):
if len(self.lst) == 1:
return lst[0]
else:
return self.lst[0].add(self.recurs(lst[1:])
See Question&Answers more detail:os