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 trialJames Gill
Courses Plus Student 34,936 PointsPython Collections: Lists Redux, Manipulating Lists, Challenge 2 of 3 doesn't work?
No matter what methods I use to get the answer, I get the "Oops! It looks like Task 1 is no longer passing." This is an easy challenge, with several ways to do it. I tried iterating over the list, deleting items one by one, etc. Always seeing the message. Anybody else?
3 Answers
Kenneth Love
Treehouse Guest TeacherUse .pop()
and .insert()
for the first step.
Use .remove()
for the second step. You can use del
, but it'll be trickier because you'll have to keep track of the indexes somewhere.
James Gill
Courses Plus Student 34,936 PointsThanks. I double-dog pinky swear I did that--but pasting in your code made it work. Ah well.
Kenneth Love
Treehouse Guest TeacherIt's all good!
I know the CC is a bit mind-mangling with having to track the state of the list. I promise that that's on purpose :)
Richard Boag
5,547 PointsSo the breakdown of the command reads like this?
the_list.insert(0, the_list.pop(3))
Insert at place value 0
But I don't quite understand how the_list.pop(3) puts the number 1 in that place value spot. Thanks for the site, I'm loving it!
Kenneth Love
Treehouse Guest Teacherthe_list.pop(3)
finds the fourth item in the list (0, 1, 2, 3) and takes it out of the list. You could use this to put that item into a variable with something like item = the_list.pop(3)
but we don't need to.
Then, when we do the the_list.insert()
, we're putting the value that .pop()
got back into the list.
James Gill
Courses Plus Student 34,936 PointsJames Gill
Courses Plus Student 34,936 PointsI tried that. The first step passes fine, but anything I try for step 2 throws an error that step 1 isn't passing anymore. I assume I don't modify the code entered in step 1.
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherNope, don't need to modify step 1's code at all.
will pass steps 1 and 2
Joshua Lawson
4,953 PointsJoshua Lawson
4,953 PointsTHANK YOU for this. I was about to have my cat take a stab at completing the challenge!