def tri_selection(tab): for _ in range(len(tab) - 1): for j in range(len(tab)-1): if tab[j] == 0: temp = tab[j] tab[j] = tab[j+1] tab[j+1] = temp return tab liste = [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0] tri1 = tri_selection(liste) print(liste) print(tri1)