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
>>> l = ['a', 'b', 'c', 'd']
>>> l.pop(0)
'a'
>>> l
['b', 'c', 'd']
>>>
xxxxxxxxxx
my_list = [1, 2, 3, 4, 5]
# Removing the first element using the pop() method
first_element = my_list.pop(0)
print(first_element) # Output: 1
print(my_list) # Output: [2, 3, 4, 5]