python pop element from list by index code example
Example 1: how to remove an element in a list by index python
list = [0, 1, 2, 3, 4, 5]
print(list)
del list[0]
print(list)
del list[-2]
print(list)
del list[0:2]
print(list)
Example 2: how to remove element from specific index in list in python
list.pop(index)
Example 3: python pop element
my_list = [123, 'Add', 'Grepper', 'Answer']
my_list.pop()
-->[123, 'Add', 'Grepper']
my_list = [123, 'Add', 'Grepper', 'Answer']
my_list.pop(0)
-->['Add', 'Grepper', 'Answer']
my_list = [123, 'Add', 'Grepper', 'Answer']
any_index_of_the_list = 2
my_list.pop(any_index_of_the_list)
-->[123, 'Add', 'Answer']