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 trialJS Park
15,959 PointsMy code works on my terminal, but doesn't pass my test.
def reverse_evens(iterable): return iterable[::-2]
The above code returns [5,3,1] from [1,2,3,4,5], but it is not passing the test. Why is this?
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! It would pass with that list, but it won't pass with every list. Your algorithm right now assumes that the list has an odd number of elements, but take a look at what happens when you pass in [1, 2, 3, 4, 5, 6] instead. You need to take into account what happens when a list is sent in that has an even number of elements as well.
Hope this helps!
JS Park
15,959 PointsJS Park
15,959 PointsOh right, thank you! :)