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 (Retired) Slices Slice Functions

Shadow Skillz
Shadow Skillz
3,020 Points

Make a function named odds that accepts an iterable as an argument and returns the items with an odd index in the iterab

having an issues with this challenge can't figure out what I'm missing pls help

slices.py
def first_4(happy): 
    return happy[:4]

def odds(confusion):
    return confusion[::3]
Shadow Skillz
Shadow Skillz
3,020 Points

Thanks Joshua i appreciate the help

3 Answers

Joshua Edwards
Joshua Edwards
52,175 Points

Your odds function is jumping by too much. You want to start at index 1 the first odd number, and go through all the other odd numbers which are 2 steps after the previous odd number each time.

Ben Wong
Ben Wong
19,426 Points

def odds(confusion): return confusion[1::2]

Try this

  def odds(whatever):
    return whatever[1::2]