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 trialNoah Harness
1,383 PointsHELP ME PLEASE
Alright, my list is messy! Help me clean it up! First, start by 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 takes you more than one step, though!
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
for list in messy_list:
list = messy_list.insert(0, messy_list.pop(3))
return list
# Your code goes below here
4 Answers
andren
28,558 PointsYou should avoid making multiple posts for the same issue. Anyway your previous attempt was pretty close, and in this attempt you solved the issue with the previous attempt but introduced a new error.
Your for loop is incorrect, and not actually needed for the task. But you have actually figured out how to format the input method correctly.
If you remove your loop and return statement and just keep the insert code like this:
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
messy_list.insert(0, messy_list.pop(3))
Then you will be able to pass to the next task.
f4u57
6,743 Pointsmessy_list.insert(0,messy_list.pop(3))
Learnmore Jewure
5,234 Pointsmessy_list = ["a", 2, 3, 1, False, [1, 2, 3]] new = messy_list.pop(3) messy_list.insert(0, new)
messy_list.remove("a") messy_list.remove(False)
print(messy_list)
Shelley Brown
7,613 PointsThis works too.
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
messy_list.pop(3) messy_list.insert(0, 1)