remove items from list python by index code example

Example 1: remove element from list

>>> a = [0, 2, 3, 2]
>>> a.remove(2)
>>> a
[0, 3, 2]

Example 2: delete a value in list python

list.remove(element)

Example 3: python list remove item by value

l = ['Alice', 'Bob', 'Charlie', 'Bob', 'Dave']
print(l)
# ['Alice', 'Bob', 'Charlie', 'Bob', 'Dave']

l.remove('Alice')
print(l)
# ['Bob', 'Charlie', 'Bob', 'Dave']

Example 4: how to remove an item from a certain index in python

arr = [0, 1, 2, 3, 4]
del arr[1]
# arr is now equal to [0, 2, 3, 4]