How to Remove List Item of Specified Index in Python


In this example, we will learn how to remove the list item of the specified index using the pop() method in Python.

Source Code

my_list = ['a', 'b', 'c', 'd', 'e']
my_list.pop(2)    #  index is specified
print(my_list)
my_list.pop()     # index is not specified
print(my_list)

Output:

['a', 'b', 'd', 'e']
['a', 'b', 'd']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement