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 trial

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

walter fernandez
walter fernandez
4,992 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.

slices.py
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
MOD
Chris Freeman
Treehouse Moderator 68,457 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!!!