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

for the manipulating list 2nd part code challenge I used: del the_list[1] del the_list[4] del the_list[5] got error

the_list.insert(0,the_list.pop(3)) del the_list[1] del the_list[4] del the_list[5]

says first task not passing anymore.

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

# Your code goes below here
the_list.insert(0,the_list.pop(3))
del the_list[1]
del the_list[4]
del the_list[5]

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

The list starts off with 6 items, so the last item, the inner list, is index 5. When you delete two items, now the last item's index is 3, not 5, so you can't do del the_list[5] anymore.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Well, this particular part I'd do with del the_list[3] since that's the last index.

Ahmed Elsawey
Ahmed Elsawey
Courses Plus Student 3,527 Points

To be honest I used to love programming until it came to the dictionaries lists and tuples, I have no idea what to do in them and I copy the answer from some questions without even understanding them.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Aww, I don't want you to hate programming!

What are some things that confuse you about dicts/lists? Feel free to email me if you want.

Ahmed Elsawey
Ahmed Elsawey
Courses Plus Student 3,527 Points

For example now, I do not know how to do task 2 of this challenge