xxxxxxxxxx
>>> l = ['a', 'b', 'c', 'd']
>>> l.pop(0)
'a'
>>> l
['b', 'c', 'd']
>>>
xxxxxxxxxx
>>> l = [1, 2, 3, 4, 5]
>>> l
[1, 2, 3, 4, 5]
>>> l.pop(0)
1
>>> l
[2, 3, 4, 5]
xxxxxxxxxx
# delete n from last
n=3
a=[1,2,3,4,5,6,7,8,9,10]
del a[-n:]
print(a)
# [1, 2, 3, 4, 5, 6, 7]
xxxxxxxxxx
sample_list = [1, 2, 3, 4, 5]
sample_list.remove(sample_list[0])
print(sample_list)
xxxxxxxxxx
# Python3 code to demonstrate
# removing front element
# using pop(0)
# initializing list
test_list = [1, 4, 3, 6, 7]
# Printing original list
print ("Original list is : " + str(test_list))
# using pop(0) to
# perform removal
test_list.pop(0)
# Printing modified list
print ("Modified list is : " + str(test_list))