0
Is there a way to delete an element from a list?
5 odpowiedzi
+ 11
namelist = ["john","marc"]
namelist.append("sara")
>>> del namelist[0]
>>> namelist
["marc","sara"]
Or
namelist.remove(namelist[0])
Or
namelist.remove("marc")
To delete all the items
namelist.clear()
If you want to delete the last element
>>> a = [1,2,3,4,5]
>>> a.pop()
5
and ... if you want to delete the first element
>>> a.pop(0)
1
The lenght of 'a' (the list)
len(a)
+ 2
yes.you can use remove() func to delete an element from a list
+ 1
thanks!
0
excellent detail of examples to show practice in the how to correctly fill what is to be deleted in all functional possible ablities to do so as answering to specific question was done nicely for even me. thank u
0
Giovanni Gatto, thank you for additional knowledge!