What's thedifference between pop(), del, clear() function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's thedifference between pop(), del, clear() function?

https://code.sololearn.com/c3XM548V1GxB/?ref=app

23rd Jan 2019, 2:02 PM
Ashutosh Dash
Ashutosh Dash - avatar
3 Answers
+ 2
pop removes and returns the last value of the list or the given index value. del removes the given index value. clear clears the whole list. And you didn't ask for it, but remove removes the first occurence of a given value.
23rd Jan 2019, 2:32 PM
Zen
Zen - avatar
+ 1
If you want to use the element you are removing, use pop, otherwise use del.
25th Jan 2019, 9:34 AM
Zen
Zen - avatar
0
Zen Am I free to choose between pop and del? Like, is there any situation where pop will apply but not del and vice versa.!!?
25th Jan 2019, 8:03 AM
Ashutosh Dash
Ashutosh Dash - avatar