
Derick Ho
3,113 PointsWhy is my answer still wrong?
The solution is correct but it won't let me continue because it tells me that the solution is wrong. although i tested the code and it returns exactly what it is asking for. This problem is specific to the problem of reverse_evens problem
def first_4(items):
return items[:4]
def first_and_last_4(items):
first = items[:4]
second = items[-4:]
first.extend(second)
return first
def odds(items):
return items[1::2]
def reverse_evens(items):
return items[-1::-2]
1 Answer

Steven Parker
204,727 PointsYour solution might seem correct when tested with "lucky data". It will produce the expected output half of the time.
There's two strategies that will yield correct output in all cases:
- compute the starting position based on the length (actually even/odd-ness) of the list
- extract the even indexed items first, and then reverse them in a separate operation
Hint: Either method works when correctly implemented, but the second one might be a bit simpler to do.
Derick Ho
3,113 PointsDerick Ho
3,113 PointsThank You! You were correct.