0

Is there a way to delete an element from a list?

12th Sep 2016, 5:03 PM
Odisher 7
Odisher 7 - avatar
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)
12th Sep 2016, 6:20 PM
Giovanni Gatto
Giovanni Gatto - avatar
+ 2
yes.you can use remove() func to delete an element from a list
12th Sep 2016, 5:10 PM
manonmani.m
+ 1
thanks!
12th Sep 2016, 5:42 PM
Odisher 7
Odisher 7 - avatar
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
12th Sep 2016, 7:48 PM
Mark Ferris
Mark Ferris - avatar
0
Giovanni Gatto, thank you for additional knowledge!
13th Sep 2016, 8:44 AM
Sergey Martynov
Sergey Martynov - avatar