I need to write a recursive function that calculates all the possible combinations of length "n" in a list, in Python, without importing anything like itertools
etc.
So what I have so far is:
if n == 0:
return [[]]
elif lst == []:
return []
else:
rest = subsets(lst[1:], n-1)
for next in lst: # Loop through something?
return lst[0] + rest #Add something?
I seem to be lacking an understanding of how the recursive calls work, can someone explain this to me?