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 Collections (2016, retired 2019) Lists Removing items from a list

messy_list issue

I thought this would be easy. Of the indices I want to delete (0,4,5), I'd start with the highest so as not to mess up the index positions. So I removed 5, then 4, and finally 0. It worked in workspaces.

lists.py
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]

# Your code goes below here
del messy_list[5]
del messy_list[4]
del messy_list[0]

2 Answers

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

In task 1 of 2 you move the 1 (index 3) to index 0, and then messy_list would look like this:

messy_list = [1, "a", 2, 3, False, [1, 2, 3]]

Remember to not remove the code from task 1, because this will make the code fail.

Steven Parker
Steven Parker
231,236 Points

But the instructions don't say to just remove items. In fact, task 1 says "start by moving the 1 from index 3 to index 0".

So for task 1, you will only be changing the order, nothing will be permanently removed. Then in task 2 you'll remove things from the re-ordered list.

In all multi-task challenges each task build on the previous one. Unless the instructions explicitly say otherwise, each task's code will remain as-is while you add code for the next.