How to nest loops N number of times python

Question:

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
Asked By: Ebrahim Momin

||

Answers:

You can do that with recursion

def func(N)
    if N == 0: return
    for i in range(N):
        #do something
    return func(N-1)
Answered By: Dmiich
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.