I'm trying to find a way to enumerate all combinations of a list of numbers without recursion or using itertools. I came up with a solution that works but I think it turned into a recursive function after all. I'm new to Python and not sure how I would make this work without recursion.
Any help is appreciated as I think I'm still failing to see the difference between the two.
result = []
def permutation(li):
if len(li) == 1:
result.append(li[0])
print (result)
result.pop()
return
for i in range(0,len(li)):
result.append(li[i])
permutation(li[:i] + li[i+1:])
result.pop()
permutation([1,2,3])