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

walter fernandez
walter fernandez
4,991 Points

hello, I am having some issues doing the last function. Just check the last function (it is the answer of this challenge

When I run the code in IDLE I get the correct answer, but I don't know what the challenge is expecting me to do.
def first_4(p):
    return p[:4]

def first_and_last_4(t):
    return t[:4] + t[-4:]

def odds(z):
    z = []
    for i in z:
        if i % 2 == 1 :
        return z    

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 60,543 Points

The odds function is supposed to return the odd-number indexed items from the iterable. You are checking if the value of z is literally odd.

Also, by assigning z = [] you override the input value z making the argument inaccessible.

Post back if you need more help. Good luck!!!