programming-examples/python/Misc/Python program to the push the first number to the end of a list.py

11 lines
348 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def move_last(num_list):
a = [num_list[0] for i in range(num_list.count(num_list[0]))]
x = [ i for i in num_list if i != num_list[0]]
x.extend(a)
return(x)
l1 = [0,2,3,4,6,7,10]
l2 = [10,0,11,12,14,0,17]
print("Original List: ",l1)
print(move_last(l1))
print("Original List: ",l2)
print(move_last(l2))