python remove element from array 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: remove value from python list by value
>>> a = ['a', 'b', 'c', 'd']
>>> a.remove('b')
>>> print a
['a', 'c', 'd']
Example 3: python remove one element from array
array = ["red", "green", "blue"]
del array[0]
Example 4: how to remove element from list python by index
>>> l = [1, 2, 43, 3, 4]
>>> l.pop(2)
43
>>> l
[1, 2, 3, 4]
Example 5: python remove by index
a = [0, 1, 2, 3, 4, 5]
el = a.pop(2)
Example 6: how to remove an item from a certain index in python
arr = [0, 1, 2, 3, 4]
del arr[1]