Python Python Collections (2016, retired 2019) Slices Slice Functions

Tom Finch
Tom Finch
987 Points

Not sure what its asking here.

When I run this code outside of the challenge I get what I believe to be the correct result.

e.g if I had a list of numbers from 1 - 10 and ran it through the odds function It would return the numbers (2, 4, 6, 8, 10) with the Index being odd numbers. (1, 3, 5, 7, 9).

but in the challenge it get "Didn't get the right value for odds".

Any idea what I am doing wrong?
def first_4(items):
    return items[:4]

def first_and_last_4(items):
    first4 = items[:4]
    last4 = items[-4:]
    both = first4 + last4

def odds(items):
    oddItems = items[1::2]
Tom Finch
Tom Finch
987 Points

never mind, I see that I have used [] for return.

1 Answer

Steven Parker
Steven Parker
207,983 Points

Also, "return" is not a function, so you don't need parentheses around the result either:

    return both  # instead of: return(both)