0

I'm creating a program, which needs to nest loops N number of times. Is there any way to do this? Or do I need to do it manually?

Wanted result:

for i in range(N):
    #Do something
    for i in range(N-1):
        #Do something
        for i in range(N-2):
            #Etc, continues until the value in range is 0

1 Answers1

3

You can do that with recursion

def func(N)
    if N == 0: return
    for i in range(N):
        #do something
    return func(N-1)
Dmiich
  • 325
  • 2
  • 16