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 trialDennis Pilat
2,115 PointsBummer! 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.
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
Courses Plus Student 26,868 PointsUse .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]
Emily Sue
1,769 PointsEmily Sue
1,769 PointsI 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