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 trialJohn Rytel
2,533 Pointsreverse_evens() works on workspaces but doesn't on the challenge website.
I am on the last part of the coding challenge for slices, and the function should return all the even index's backward. When I test my code in the workspace it does just that, but on the challenge website, the only error that I get is that the answer is not right. Any help?
def first_4(iterable):
slice = iterable[:4]
return slice
def first_and_last_4(iterable):
slice = iterable[:4] + iterable[-4:]
return slice
def odds(iterable):
slice = iterable[1::2]
return slice
def reverse_evens(iterable):
slice = iterable[::-2]
return slice
1 Answer
Istvan Nonn
2,092 PointsI have the same problem in the last part. I tried different approaches like:
def reverse_evens(item):
return item[::-2]
or
def reverse_evens(item):
return item[-1::-2]
or
def reverse_evens(item):
return item[-2::-2]
or even excluding 0(zero)
def reverse_evens(item):
return item[-2:1:-2]
For sure the answer is in front of me, just can't see because is a simple solution.
Istvan Nonn
2,092 PointsIstvan Nonn
2,092 PointsI made it ... Thanks to Jennifer Nordell
Please read carefully and you can do it! I am not going to give just yet the final answer.