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 trialKaleshe Alleyne-Vassel
8,466 PointsCan't see where I am going wrong. I've tested this code elsewhere and it seems to do the job but not here...
As instructed by the last part of the challenge, I attempted to create a function that will reverse and only include the even index. I'm not sure what to do and was only able to come up with this.
def reverse_evens(target):
return target[::-2]
def reverse_evens(target):
return target[::-2]
def first_4(target):
return target[0:4]
def first_and_last_4(target):
first = target[0:4]
last = target[-4:]
result = first + last
return result
def odds(target):
return target[1::2]
1 Answer
John Goodwin
17,921 PointsHi Kaleshe,
I can see where you're going with your code. See if you can break it down into multiple steps and first reverse the list, and then take the even index items.
Kaleshe Alleyne-Vassel
8,466 PointsKaleshe Alleyne-Vassel
8,466 PointsSolved!