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

Not sure what to do here with lists.py challenge - 2nd task.

I'm going through the list methods individually, in sequential order - but I'm not sure if I am missing the point and should have created something else to iterate through the list. I found the solution pretty easily on the first half of the challenge. Anyone who can help me stay on track with the 2nd half of this challenge - I would appreciate it. I feel like maybe I am not understanding just what is being asked for in this challenge. Thank you.

lists.py
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
first_step = messy_list.pop(3)
second_step = messy_list.insert(0, first_step)
third_step = messy_list.remove([1, 2, 3])
del messy_list(1)
del messy_list(-1)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

You are SO close. The del operator deletes a specific object. By using parens in del messy_list(1) you're asking Python to remove the function call messy_list(1), which does not exist. To deleted the list item at index 1, use square brackets or braces: del messy_list[1]. Same goes for the other del statement.

Post back if you have more questions! Good Luck!!

That worked, sir. I can move on now. Thank you very much. I was closer than I thought : )