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 (Retired) Lists Redux Manipulating Lists

Bummer! Try again! Challenge Task 2 of 3

Use .remove() and/or del to remove the string, boolean, and last list.

I don't understand what I'm getting wrong.

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

# Your code goes below here
the_list.pop(3)
the_list.insert(0,1)

del the_list(1)
del the_list(4)
del the_list(5)
del the_list(6)
del the_list(7)

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Use .remove() and/or del to remove the string, boolean, and list members of the_list.


Hi, Dennis, this part of challenges asks for removing only string, boolean, and list members from the list, your code is obviously removing way too many elements; there're only 3 items that fit the requirement. "a" False and [1, 2, 3].

You may remove them in whatever order you like, but the easiest way is to delete them backward, that way you don't need to worry about the shrinking list length.

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

# Your code goes below here
the_list.pop(3)
the_list.insert(0,1)

del the_list[5]
del the_list[4]
del the_list[1]

I tried to delete in whatever order I wanted and it didn't work. I put it in the order you had and it worked. I think there's a specific order