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 trialLeah Kelly
4,141 Pointswhat is the difference between .remove() and del()???
they're both deleting items in a list, what's the diff?
2 Answers
Steven Parker
231,275 PointsThe main difference between these is how you identify what is to be deleted.
With .remove
, you specify the contents of the item, and the first one that matches is deleted.
With del
, you specify the specific item by index (or several items by index range).
Leah Kelly
4,141 Points😊 thanks, that makes more sense.