I need to write a function that receives an non-negative integer and returns:
[] for n=0
[[]] for n=1
[[],[[]]] for n=2
[[],[[]],[[],[[]]]] for n=3
And so on. For n, we will receive an n sized list, so that in index i there will be all the i-1 elements from the list. I don't know how to explain that better, English isn't my first language.
I'm not allowed to use list slicing or loops and I'm supposed to create deep copies of each list, without the copy module. I'm not allowed to let 2 different lists or indexes point to the same list in memory.
This is what I tried:
def list_seq(x, outer_list=[]):
if x == 0:
return []
outer_list.append(list_seq(x-1,outer_list))
return outer_list
And the output for print(list_seq(2)) is [[], [...]].