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 Python Basics (2015) Python Data Types List cleanup

ALEJANDRO ALANIS
ALEJANDRO ALANIS
327 Points

Python Basics challenge Task 1 of 2. I need to use 'del' on my code and I am, but I get an error saying I didn't used it

Python Basics challenge Task 1 of 2. I need to use 'del' on my code and I am, but I get an error saying I didn't used it. I think I'm right, but I need help if I'm doing it worng. Thanks!

lists.py
messy = [5, 2, 8, 1, 3]
messy_list = list(messy)
del messy_list[2]

2 Answers

K Cleveland
K Cleveland
21,839 Points

The challenge asks you to: "Use del to delete the 8 from messy."

Your code reads like this:

messy = [5, 2, 8, 1, 3]
messy_list = list(messy)
del messy_list[2]

The challenge asks you to delete 8 from messy, not messy_list. Hope this helps!

ALEJANDRO ALANIS
ALEJANDRO ALANIS
327 Points

I thought I needed to turn it into a list... oh my. But yeah it did worked, haha, thanks!

K Cleveland
K Cleveland
21,839 Points

Glad it worked out!