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 trialmamadou diene
Python Web Development Techdegree Student 1,971 PointsGreat! 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
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
Steve Hunter
57,712 PointsHi 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 pop
ped 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
7,311 PointsYes, 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.
Adam N
70,280 Points.remove() can only remove one thing at a time.
Please mark my response as the 'best answer' if it helps you out!
Steve Hunter
57,712 PointsShould 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.
mamadou diene
Python Web Development Techdegree Student 1,971 Pointsstill 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)
Steve Hunter
57,712 PointsI 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.
Adam N
70,280 PointsSteve Hunter You're right. I must've went wrong somewhere.