In this example we will show how to remove the list item of the specified index using the del keyword in Python.
Source Code
my_list = ['a', 'b', 'c', 'd', 'e']
del my_list[2]
print(my_list)
Output:
['a', 'b', 'd', 'e']
In this example we will show how to remove the list item of the specified index using the del keyword in Python.
my_list = ['a', 'b', 'c', 'd', 'e']
del my_list[2]
print(my_list)
Output:
['a', 'b', 'd', 'e']
In this example we will show how to remove the list item of the specified index using the pop() method in Python.
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']