python list.del code example
Example 1: delete element list python
list.remove(element)
Example 2: delete all elements in list python
mylist = [1, 2, 3, 4]
mylist.clear()
print(mylist)
# []
Example 3: python list .remove
a = [10, 20, 30, 20]
a.remove(20)
# a = [10, 30, 20]
# removed first instance of argument
Example 4: delete a row in list python
del liste[number]
Example 5: remove item from list python
l = list[1, 2, 3, 4]
for i in range(len(list)):
l.pop(i) # OR "l.remove(i)"
Example 6: del list python
>>> a=[1,2,3]
>>> a.remove(2)
>>> a
[1, 3]
>>> a=[1,2,3]
>>> del a[1]
>>> a
[1, 3]
>>> a= [1,2,3]
>>> a.pop(1)
2
>>> a
[1, 3]
>>>