list1=[i for i in range(1,40)]
print(list1)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]
while len(list1)>2:
list2=list1[0:2]
list1.append(list2[0])
list1.append(list2[1])
del list1[0:3]
print(list1)
[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2]
[7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5]
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8]
[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11]
[16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14]
[19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17]
[22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]
[25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23]
[28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26]
[31, 32, 33, 34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]
[34, 35, 36, 37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32]
[37, 38, 39, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35]
[1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38]
[5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 1, 2]
[10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 1, 2, 5, 7]
[14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 1, 2, 5, 7, 10, 11]
[19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 1, 2, 5, 7, 10, 11, 14, 16]
[23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 1, 2, 5, 7, 10, 11, 14, 16, 19, 20]
[28, 29, 31, 32, 34, 35, 37, 38, 1, 2, 5, 7, 10, 11, 14, 16, 19, 20, 23, 25]
[32, 34, 35, 37, 38, 1, 2, 5, 7, 10, 11, 14, 16, 19, 20, 23, 25, 28, 29]
[37, 38, 1, 2, 5, 7, 10, 11, 14, 16, 19, 20, 23, 25, 28, 29, 32, 34]
[2, 5, 7, 10, 11, 14, 16, 19, 20, 23, 25, 28, 29, 32, 34, 37, 38]
[10, 11, 14, 16, 19, 20, 23, 25, 28, 29, 32, 34, 37, 38, 2, 5]
[16, 19, 20, 23, 25, 28, 29, 32, 34, 37, 38, 2, 5, 10, 11]
[23, 25, 28, 29, 32, 34, 37, 38, 2, 5, 10, 11, 16, 19]
[29, 32, 34, 37, 38, 2, 5, 10, 11, 16, 19, 23, 25]
[37, 38, 2, 5, 10, 11, 16, 19, 23, 25, 29, 32]
[5, 10, 11, 16, 19, 23, 25, 29, 32, 37, 38]
[16, 19, 23, 25, 29, 32, 37, 38, 5, 10]
[25, 29, 32, 37, 38, 5, 10, 16, 19]
[37, 38, 5, 10, 16, 19, 25, 29]
[10, 16, 19, 25, 29, 37, 38]
[25, 29, 37, 38, 10, 16]
[38, 10, 16, 25, 29]
[25, 29, 38, 10]
[10, 25, 29]
[10, 25]