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 trialelad shor leshem
1,916 Pointsreverse_evens - why im getting rejected?
the "reverse_evens" def is longer but it works, why im getting rejected? tnx
def first_4(arg1):
return arg1[0:4]
def first_and_last_4(arg1):
a = arg1[0:4]
b = arg1[-4:]
return a + b
def odds(arg1):
return arg1[1::2]
def reverse_evens(arg1):
rev_arg1 = arg1[::-1]
return rev_arg1[::2]
1 Answer
Mike Wagner
23,559 PointsWith an even-length list, using your method, the function essentially returns the odd indices of the original iterable. You'll have to find a way to retrieve the even indices of the original iterable in a way that either checks and accounts for iterables of odd-length, or that satisfies the requirements of both an odd- or even-length iterable. Note: I'm referring to the original iterable as a bit of a hint at how to think of the problem.
If you need a bit more help, feel free to say something. I'll tell you now that you are incredibly close.