Delete a list of three ways (python)

del is a statement rather than a method

del member [1]: to delete by the subscript

del member: You can also delete the entire list

 

remove (): to delete the list elements themselves, rather than by the subscript

member.remove('天天')

 

pop():

member.pop (): default throws the last element in the list,

name = member.pop (): and can be thrown elements assignment.

member.pop (1): the element can also be deleted by the subscript

 

Guess you like

Origin www.cnblogs.com/huashu2019/p/11247118.html