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

Ahmed Elsawey
PLUS
Ahmed Elsawey
Courses Plus Student 3,527 Points

How do I do this please anyone help? and checkout my other questions as I have no clue what the answers could be

I need to move the 1 to the beginning of the list but I have no idea how to do this. Ricky Catron

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

# Your code goes below here
num = the_list.pop(idx)
the_list[0] = num

1 Answer

Ricky Catron
Ricky Catron
13,023 Points

I have been summoned!

Your code looks like a good start!

Your first line:

num = the_list.pop(idx)

looks good but you either need to make idx equal to the index of where 1 is in the list OR simply put the index that 1 is at directly into the function.

Example if 1 was at index 5:

num = the_list.pop(5)

and for your second line, right now you are overriding the information at index 0 with the value stored in num. Instead what you need to do is INSERT num at index 0.

Example of inserting it at index 5:

list.insert(5,num)

Goodluck! --Ricky