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 trialGeorge Lugo
Python Web Development Techdegree Student 922 Pointswhat am i doing wrong with the code
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]] return(messy_list.pop(3) and messy_list.insert(0, 3)
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
return(messy_list.pop(3) and messy_list.insert(0, 3)
1 Answer
Nick deLannoy
16,863 PointsFirst of all, the return keyword needs to be used within a function, you don't need to use that here.
This task is asking you to move the 1 in the list, so you need to get that 1 first. You got that part right.
messy_list.pop(3)
This will remove the 1 and return it
You also need to put the 1 at index 0, and you can do that with
messy_list.insert(0, 1)
so, if you want to immediately take out the 1 and put it back in index 0, you can put the .pop() call within the insert call:
messy_list.insert(0, messy_list.pop(3))