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

It keeps saying I cant just add another list but move it. What am i doing wrong?

What am I forgetting to do?

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

# Your code goes below here

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

Hi Bryce,

I don't know if it was by accident but you opened this question 12 times. Please, for future use, open a question just once, someone will help you out eventually. If it takes some time to post the question, please just wait a bit until it is up on the board. :)

Elian

2 Answers

rydavim
rydavim
18,813 Points

Welcome to Treehouse!

I don't have a ton of experience with Python, but I think I can help you with this. Let's walk through your code...

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

the_list.pop(0) # This is removing the "a" at index 0. You want to remove the 1 at index 3.
the_list.insert(0,1) # This is inserting a new 1 at index 0.

# You can do this in one step by using the pop method inside insert.
the_list.insert(0, the_list.pop(3)); # Pop the value at index 3 and insert it at index 0.

Remember that the index values of a list start at 0. This will be important in the rest of the challenge.

Please let me know if anything is unclear, or if you get stuck on the other challenge steps. Happy coding! :)

Seth Reece
Seth Reece
32,867 Points

Hi Bryce,

The challenge is asking you to move the "1". It is at index 3, not 0.

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

passes for me.