Mar-05-2019, 03:13 PM
List = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] step = 4 def ResetCR (l, stp): 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) if stp == 0: return K F = ResetCR(List,step) print (F)I'm trying to change the order of a list. If the "K = []" is out side the function, it works. However, I'm wondering is there a way to keep the variable 'K' inside the function?