def makelist(list): leng = len(list) #集合长度 if leng >= 3 : tempList = copy.deepcopy(list) newList = [] va = int(leng / 3) yu = leng % 3 for i in range(1,va+1): tempList.remove(list[i * 3-1]) for i in range(1, yu+1): #清除余数 newList.append(list[va*3+i-1]) tempList.remove(list[va*3+i-1]) for value in tempList: newList.append(value) return makelist(newList) else: return list list =[] #创建list for i in range(1,51): list.append(i) print(list) newList = makelist(list) print(newList)