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)
![Dorota Parzych](https://uploads.teamtreehouse.com/production/profile-photos/10735860/micro_69002368_2431039847220518_2779241459994329088_o.jpg)
Dorota Parzych
5,706 Pointspop() - what was this function exactly doing?
I forgot what the pop() function was doing and why it influences our display_wishlist function Thanks in advance
2 Answers
![adrian miranda](https://secure.gravatar.com/avatar/fcdf6c268e35635a453e38444b69c7f8?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
adrian miranda
13,561 PointsWhen you call pop() on a list, it gives you the last element on the list. However, it also modifies the list, actually removing the last element.
Or if you call pop(0) on a list, it removes the first element (the zeroth element) from the list. So again, it both gives you the first element, and removes it from the list.
In display_wishlist they use pop(0) to remove the first element, and print it with some fancy formatting. Later they go through and print everything in the list, but they don't wind up printing the first element again, because it was removed by the call to pop(0).
![Dan B](https://secure.gravatar.com/avatar/a04abfc47ab78e78419a2642cd87ba2a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Dan B
6,155 PointsGood question, I had the same one. The reason it wasn't used because pop edits the list as the teacher showed. He did this deliberately to show how easy it is to accidentally change a list. You should definitely use
wishes[0]
If you don't want to edit the list like the pop function does.