Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Eswar Ambati](https://uploads.teamtreehouse.com/production/profile-photos/10174532/micro_140897.jpg)
Eswar Ambati
890 PointsDifference between del and pop
In the video at 3:54 I had a misunderstanding f what del really was.
This is because it was mentioned that del can be used when you don twant the value around and u want it to be garbage collected. However the value is still around due to such variable having the ability to store the value. As usin del only removes the label and not the actual value. Unlike pop
This might be my misunderstanding hopefully it can be cleared
3 Answers
![Jason Wiram](https://uploads.teamtreehouse.com/production/profile-photos/87526/micro_Moody_profile_crop.jpeg)
Jason Wiram
42,762 PointsThe previous answer is not entirely correct. del removes an item at a specific index
> yourArray = [3, 2, 2, 1]
> del yourArray[1]
[3, 2, 1]
pop removes an item at a specific index (and returns it)
> yourArray = [4, 3, 5]
> yourArray.pop(1)
3
> yourArray
[4, 5]
![waelitox](https://uploads.teamtreehouse.com/production/profile-photos/10432022/micro_white-smiley-face-png-20.jpg)
waelitox
2,574 PointsIf pop is a method to the object list, e.g., books.pop(), what is the classification of del? Is it also a method? If so, how come it is done or written in a different way than all the methods we have learnt thus far?
Thanks.
![Ewerton Luna](https://uploads.teamtreehouse.com/production/profile-photos/9660962/micro_e61bac45-b785-4f66-bc75-51475359b181.jpg)
Ewerton Luna
Full Stack JavaScript Techdegree Graduate 24,031 PointsI believe, as Craig said, del is simply a statement, not a method. This statement remove a certain label from an object. If this object doesn't get a new label before the del statement is used, it will be garbage collected, since you can no longer access it.
![Aaron Hinesley](https://uploads.teamtreehouse.com/production/profile-photos/10252562/micro_28870294_1920885474588878_5228955728489915643_n.jpg)
Aaron Hinesley
2,993 PointsHere is what I used to help me know the difference. If you use delete, you have to write more code to keep the value: example1 = "Hello"
example2 = example1
del example1
So now the string is saved with a new label. But there must be an easier way to do this right? That's when pop becomes the better way to do this.
example1 = ["Hello"]
example2 = books.pop()
Now the string is removed from the list and already has a new label with less script! I hope this helps in any way.
![tangybit](https://secure.gravatar.com/avatar/1aa68374b3b65d2d284abc08926fbc69?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
tangybit
6,777 PointsWhat happens when you simply run books.pop(1) without assigning it to a variable? Is books(1) completely removed in that case or is it stored somewhere? If the latter, where is it stored?
![Mark Nembhard](https://secure.gravatar.com/avatar/ff16d556c674b5ad4a39d15d94b72d2a?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mark Nembhard
1,387 PointsLike it. But then why have Del on its own when you have pop that can manage both tasks
![Aaron Hinesley](https://uploads.teamtreehouse.com/production/profile-photos/10252562/micro_28870294_1920885474588878_5228955728489915643_n.jpg)
Aaron Hinesley
2,993 PointsGood question. I would think Del will come in handy if you do not want to keep the specific data around any longer. If you have duplicates of data and want to start condensing. It would be best to just delete rather than pop it out with no intentions of using it. It offers flexibility on how you want the program to handle the task. Rather than there being only one way to deal with it.
Lauritz Patterson
1,207 PointsLauritz Patterson
1,207 PointsThis was very helpful!
anthony pizarro
1,983 Pointsanthony pizarro
1,983 Points.pop seems to have "deleted" 3 in your example. yourArray no longer holds .pop(1), were is .pop(1) stored, and how can I access it, or is it gone? and why would I want to use del instead of manually removing the item from the list, in what scenario would I ever use del in?
Enrica Fedeli-Jaques
6,773 PointsEnrica Fedeli-Jaques
6,773 PointsRight! this is a good starting point for me to understand. now i need to know what happens to the items after they are popped . thank you for making it REAL simple :)