supprimer l'élément de la liste
>>> a = [0, 2, 3, 2]
>>> a.remove(2)
>>> a
[0, 3, 2]
supprimer la liste des éléments python
list.remove(element)
supprimer la valeur de la liste python par valeur
>>> a = ['a', 'b', 'c', 'd']
>>> a.remove('b')
>>> print a
['a', 'c', 'd']
python comment supprimer des éléments d'une liste
# Basic syntax:
my_list.remove(element)
# Note, .remove(element) removes the first matching element it finds in
# the list.
# Example usage:
animals = ['cat', 'dog', 'rabbit', 'guinea pig', 'rabbit']
animals.remove('rabbit')
print(animals)
--> ['cat', 'dog', 'guinea pig', 'rabbit'] # Note only 1st instance of
# rabbit was removed from the list.
# Note, if you want to remove all instances of an element, convert the
# list to a set and back to a list, and then run .remove(element) E.g.:
animals = list(set['cat', 'dog', 'rabbit', 'guinea pig', 'rabbit']))
animals.remove('rabbit')
print(animals)
--> ['cat', 'dog', 'guinea pig']
comment supprimer un élément dans une liste par index python
list = [0, 1, 2, 3, 4, 5]
print(list)
# [0, 1, 2, 3, 4, 5]
del list[0]
print(list)
# [1, 2, 3, 4, 5]
del list[-2]
print(list)
# [1, 2, 3, 5]
del list[0:2]
print(list)
# [3, 5]
comment supprimer un élément d'un index spécifique dans la liste en python
list.pop(index)