My question is quite similar to this one here: Function with varying number of For Loops (python)
However, what I really want is for example:
def loop_rec(n):
    for i in range(n):
        for j in range(n):
            for k in range(n):
                #... n loops
                    #Do something with i, j and k 
                    #Such as i+j+k
The example in the link does not allow the index x to vary.
Something like the answer suggested in that question but to use the indices instead of just x.
def loop_rec(y, n):
    if n >= 1:
        for x in range(y): # Not just x
            loop_rec(y, n - 1)
    else:
       whatever()
Thanks
 
     
    