Mar-05-2019, 06:55 PM
(Mar-05-2019, 06:32 PM)ichabod801 Wrote: I'm not sure I understand the question. If you have a K in the function as a non-empty list, append will add to what is already in the list. But if you are defining K in the function, you will have the same problem of it resetting every time you recurse. But if you have a default, and pass the modified list each time you recurse, it doesn't reset.
Thank you! It is very helpful. I think I figured it out.
List = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] step = 4 def ResetCR (l, stp, K = None): if K is None: K = [] if stp != 0: for i in range(1, int(len(l)/stp)+1): K.append(l[i*stp - 1]) l = [x for x in l if x not in K] stp = stp - 1 return ResetCR(l,stp,K) if stp == 0: return K F = ResetCR(List,step) print (F)