I have tried to crate a recursive function that gets a number and returns a list of nested list according to the index. For example, for 0, the function returns an empty list []
. for 1, the function returns [[], [[]]]
. for 3 the function returns [ [] , [ [] ] , [ [] , [ [] ] ]]
, and so on.
def func(n):
if n == 0:
return []
return [func(n-1)]
i have tried many different approaches for this problem. I cant figure out how to extend my output to nested list according to the task.