I have task to make function to recursive. I read about it, but I m still not sure.
I have function:
arr = [1,2,3,4,5]
def cube(arr):
cube_arr = []
for el in arr:
cube_arr.append(el ** 3)
return cube_arr
So this method should go to recursive. I'm not sure what they mean by that, I just did
arr = [1,2,3,4]
def cube(arr):
cube_arr = []
if len(arr) == 0
return None
else:
for el in arr:
cube_arr.append(el ** 3)
return cube_arr
It was said it has to be Tail-recursive. Anyone have any ideas where should I look? I read about it but I can't quite get it