Q. What are the two ways to remove something from a list? How are they different?
Answer =
del operator and pop method both are used to delete the value from list .
del is used to delete the value by slice while pop is used to delete value by particular index number and also it return the deleted value.
Please give an example of this one
ReplyDeletel = [1,2,3,4,5,6,7,8,9]
Deletedel l [ 0 : 3]
#our list = [ 4,5,6,7,8,9 ]
l.pop(5)
#our list = [ 4,5,6,7,8 ]
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )