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

getting this error in lists.py "it looks like Task 1 is no longer passing"

I have done everything that was asked in question, checked it in workspace. I don't what to do now, how to remove this error message I am recieving

lists.py
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
# Your code goes below here

messy_list.insert(0, messy_list.pop(3))
messy_list.remove("a")
del messy_list[-2:]
messy_list.remove([1,2,3])
print messy_list

2 Answers

Steven Parker
Steven Parker
229,744 Points

You get that message anytime you introduce an error (anywhere in the program).

That's because it always retests all tasks in order.

In this case, you either don't need that last remove, or you could remove the colon from the slice and have it just remove one element. Either way works.

But most importantly, the instructions don't ask you to print anything.

Thanks, the colon was a mistake. I removed it but was still getting error. Thanks for pointing it out that it was cause of print.

Steven Parker
Steven Parker
229,744 Points

Happy to help. Also, I revised my answer when I realized there were two different ways to fix the code.

Shreyas Papinwar
Shreyas Papinwar
2,371 Points
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]

# here is the task one

messy_list.insert(0, messy_list.pop(3))

# here is the 2nd task

messy_list.remove("a")

# as with this line of code it will delete the last 2 items in the list, so you don't have to delete the [1, 2, 3] in list again.

del messy_list[-2:]

# there is no need to print out anything (do only things that are asked in question)