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 trialMathew Yangang
4,433 Points.pop() and .insert()
I used .pop and .insert to remove "1" from the list and put the "1" at the front of the list using .insert, but i'm still getting errors
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
messy_list.pop(1)
messy_list.insert(0,1)
# Your code goes below here
2 Answers
Mathew Yangang
4,433 Pointsabsolutely; Thanks Jason
Jason Anders
Treehouse Moderator 145,860 PointsHi Mathew,
You're on the right track, but the instructions say to remove the [integer] 1 from index 3. You are using pop(), which takes an index as the parameter. Check your code... you're passing in index one into the method instead of index 3. The rest is good.
Nice work! :)
Mathew Yangang
4,433 PointsThanks Jason, is there a way I could do all that in one statement?
Jason Anders
Treehouse Moderator 145,860 PointsYes you can. It's just a matter of a little combination. I won't give the answer outright, but an example would be:
my_list.insert(index, my_list.pop(index))
You just pop()
as the second param. Make sense?
:)