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

Manipulating lists Challenge task 3 of 3

For some reason, it's saying that 'the_list' doesn't have the right items in it. At the end of the code, I put 'the_list.extend(range(4, 21))'

4 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

This actually helped me find a place where I didn't test answers well enough. I've updated the code challenge so it should be more clear when this happens.

Thanks!

Sweet. Thanks for the response and speedy assistance!

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

So long as the_list only has [1, 2, 3] in it by that point, what you have above should work. Can you show me what code you currently have?

Oh! Sorry. When I did "the_list.pop(1)", I should have put '3' because that was the position of the "1". I confused it with the 'remove' method. Lol! It's all clear now :)

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

the_list.pop(1) the_list.insert(0, 1)

the_list.remove("a") the_list.remove(False) the_list.remove([1, 2, 3])

the_list.extend(range(4, 21))

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Did you run this in Workspaces or your local computer? There's a bug in how you're using .pop(). .pop() removes by index, not by value, so the_list.pop(1) gets back 2 (which is in the 1 index spot), so after your the_list.insert(0, 1), your the_list looks like [1, 'a', 3, 1, False, [1, 2, 3]].

Fix that bug and the rest of your code should work fine.

Andrew Merrick
Andrew Merrick
20,151 Points

Stephen:

the_list.extend(range(4,21) 

worked for me. I would advise to check your .pop() code and try again.