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 trialStefan Paolini
4,679 Pointsslices.py Task 4/4 - This seems to run fine in IDLE?
This code seems to run fine in IDLE, but for some reason is coming up bad when I do it in the coding challenge. Am I missing something? reverse_evens(iterable)
def first_4(iterable):
return iterable[:4]
def first_and_last_4(iterable):
return iterable[:4] + iterable[-4:]
def odds(iterable):
return iterable[1::2]
def reverse_evens(iterable):
if len(iterable) % 2 == 0:
return iterable[-2::-2]
else:
return iterable[-1::-2]
3 Answers
Kirsten Smith
3,484 PointsYour code worked perfectly for all four tasks for me, try restarting your browser and running again.
Stefan Paolini
4,679 Pointsyeah, it's working now. that's a relief! thanks for your responses.
Ryan Bailey
824 PointsIs there a reason this didn't work for challenge 4/4?
def reverse_evens(items):
return items[::-2]
Steven Parker
231,275 PointsThe sample above might give you a clue. If you need more help, please start a fresh question of your own.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsSame here, try again.