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 trialMarco Koopman
5,290 PointsI get the result the question wants from me but it still says it didn't get the right results
My code:
def first_4(list):
return list[:4]
def first_and_last_4(list):
new_list = list[:4] + list[-4:]
return new_list
def odds(list):
return list[1::2]
def reverse_evens(list):
reversed_list = list[::-1]
new = reversed_list[::2]
return new
The reverse_evens function returns [5,3,1] like it should. However I can't pass this question because it says that the results are wrong..
def first_4(list):
return list[:4]
def first_and_last_4(list):
new_list = list[:4] + list[-4:]
return new_list
def odds(list):
return list[1::2]
def reverse_evens(list):
reversed_list = list[::-1]
new = reversed_list[::2]
return new
3 Answers
Alexander Davison
65,469 PointsTry first getting the evens then reversing those, instead of vice versa.
def reverse_evens(list):
evens = list[::2]
return evens[::-1]
Ross Coe
5,061 Points@Macro - maybe an indentation error make sure you have a carriage return (cursor) over near the (left hand side numbers) gutter otherwise it may not think the function def reverse_evens is complete
Marco Koopman
5,290 PointsNope, the indentations are all correct. I really don't know what the problem is here.
Ross Coe
5,061 PointsI mean just at the end of the def function make sure you're back over and do an extra - that worked on something else where I knew the code was right - else reach out to support if stumped - best of luck
Marco Koopman
5,290 PointsMarco Koopman
5,290 PointsThen it says: Bummer: Couldn't find
reverse_evens
.Is this question glitched or is my code wrong?
Ross Coe
5,061 PointsRoss Coe
5,061 Pointsthanks