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

Python Introducing Lists Meet Lists Review Deletion

Ben Wiley
Ben Wiley
461 Points

I am unclear on the function of del.

If del removes the label and not the element within a list, shouldn't the len() function remain constant, regardless of how many specific items are "del"-ed?

I clearly am having some difficulty understanding the nuances of del.

1 Answer

Steven Parker
Steven Parker
231,248 Points

The "del" statement does remove an item from a list, reducing the length of the list.

What it does not delete is the object that the list element was referencing. But if there are no other references to the object, it won't be possible to access it again.