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

Robert Young
Robert Young
1,391 Points

keeps saying oops task 1 is not passing.

I have done this 7 ways to hell and it still keeps saying task 1 is no longer passing

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.del(4, 5, messy_list.remove("a"))

1 Answer

Antonio De Rose
Antonio De Rose
20,884 Points
#let us go one after the other
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]] # this is the list

# Your code goes below here
val = messy_list.pop(3) # am using pop to get rid of the index 3, and then am storing it into the val variable
messy_list.insert(0, val) # am inserting the val, into the index 0, by using insert

messy_list.remove("a") #am using remove to take 'a', from the list
messy_list.remove(False) #again just the remove, with the value False
messy_list.remove([1, 2, 3]) #again the remove, with the inner list.