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

Ranko Milic
PLUS
Ranko Milic
Courses Plus Student 1,768 Points

What's wrong with the "del messy" exercise?

Task is to delete even numbers from the list messy=[5, 2, 8, 1, 3]. I use the code:

messy = [5, 2, 8, 1, 3]

del messy[1]

del messy[-3]

The test responds with "Bummer! Did you use 'del' "? Of course I used it, and when applied in python shell, it is all OK... no even numbers any more...

And there is no spacing issue as someone has explained to other users experiencing similar situations... Anyway, in the python shell, with or without space among the list name and the argument, the del works in the same way.

Thanks for clarification...

2 Answers

It works just fine,

del messy[2]  #gets rid of the 8, Task #1
del messy[1]  #gets rid of the 2, Task #2
Ranko Milic
PLUS
Ranko Milic
Courses Plus Student 1,768 Points

Thanks Gerald, but it is just another way of removing members from the list... My way is fine as well, but it seems that the system recognizes only one sequence of deleting items... :-( Thanks, anyway, for your fast and kind help... Because of you, I was able to pass the test :-)

I agree you answer is correct, however the challenges can be very selective in what they accept.