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

Moving the 1 from index 3 to index 0. Try to do this in a single step by using both .pop() and .insert(). It's OK if it

What else do I need to do?

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

messy_list.pop(3)messy_list.insert(0, "new") 

Try doing this task by writing two lines of code instead of one.

1 Answer

Steven Tagawa
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Steven Tagawa
Python Development Techdegree Graduate 14,438 Points

Hi Karen,

You've got all the parts there, they just aren't quite arranged right. Adam has some good advice, which is to start off seeing how it would look on two lines. You'd have to do a line with .pop first, which gets the item you want and stores it in a variable, like

new = messy_list.pop(3)

and then a line inserting your variable at the beginning of the list, like

messy_list.insert(0, new)

(Don't use quote marks there, or else it'll insert the actual word "new" into your list! Make sure you use the same variable that you used for your .pop line.)

Now, if you do two lines like that, it'll pass, so if you want to try doing it in one line, don't test it yet. :) But once you see how it works in two steps, popping your item into new, and then inserting using new, you might be able to see how you can merge the .pop and the .insert together.