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

Great! Now use .remove() and/or del to remove the string, the boolean, and the list from inside of messy_list. When you'

i am getting the error message that Task 1 is not passing anymore. Please help

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

# Your code goes below here
messy_list.pop(3) and messy_list.insert(0,1)
messy_list.remove("a", False, [1, 2, 3] )

3 Answers

Hi there,

I don't think you can pass multiple parameters to remove. I used three lines to remove each item in turn.

The error you are getting is unhelpful but if task 1 did pass, it should still. Sometimes these challenges throw up messages likes that, though.

For task one, I popped the element within the insert method so it popped straight off, then back on again.

messy_list.insert(0, messy_list.pop(3))
messy_list.remove("a")
messy_list.remove(False)
messy_list.remove([1, 2, 3])

I hope that helps.

Steve.

jopapadaki
jopapadaki
7,311 Points

Yes, Steve is right, I tried for task two, combinations of del & remove * for the appropriate usage* but it didn't take it...Had to change to one type only.

.remove() can only remove one thing at a time.

Please mark my response as the 'best answer' if it helps you out!

Should remove not work for the list, then? I got through the challenge with remove([1, 2, 3]) - do you think that's incorrect? I'd be interested to know your view on this.

Steve.

still not working. here is the corrections i have done:

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

# Your code goes below here
messy_list.pop(3) and messy_list.insert(0,1)
messy_list.remove("a")
messy_list.remove(False)
del messy_list(5)

I think del takes the element number within square brackets? But think about the element number - you've removed a couple so there is no element 5 when you reach that line of code.

Steve.

Steve Hunter You're right. :sweat_smile: I must've went wrong somewhere.