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) Slices Sorting Slices

Slices challenge not completing

I am at the last step of the challenge where I am supposed to reverse messy_list and show every third item. I tried this a number of times outside the browser and works as required by the challenge. So believe the code should be fine. Nevertheless the 3rd step keeps failing. Not sure whether there is a bug or I am missing something extremely obvious. Many thanks.

lists.py
messy_list = [5, 2, 1, 3, 4, 7, 8,3, 9, -1]
clean_list = messy_list [:]
clean_list.sort()
silly_list = messy_list[::-3]

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

You code works perfectly, I'm not sure what the error you encountered? could you clarify?

After I run the 3rd step (as written above) it tells me the 2nd step is no longer passing and asks me to recheck it. Once I do that it goes again to the 3rd step, which fails again. So it is sort of stuck looping between the 2nd and the 3d step.

William Li
William Li
Courses Plus Student 26,868 Points

looks like somehow you made change to the line #1 provided by code challenge. (don't do that)

messy_list = [5, 2, 1, 3, 4, 7, 8, 0, 9, -1]  # original messy_list
messy_list = [5, 2, 1, 3, 4, 7, 8,3, 9, -1]  # messy_list shown in your code

As you can see, changing messy_list value will effect the output of your program, and thereby cause the grader check to fail.

Wow, I would have never spotted that. Now it worked but I had to restart the challenge. Thank you so much!