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

Challenge Task incorrect

The expected output for Task 2 in the Slices section of Python Collections is koao. However, the challenge does not specify that 'Oklahoma' is the string needed for the odds function.

Here is the question:

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

Can you please update it?

Thank you

slices.py
def first_4(a_list):
    a_list = list(range(1, 20))
    return a_list[:4]

def odds(odd_list):
    odd_list = 'Oklahoma'
    return odd_list[1::2]

2 Answers

Hi there,

There's no need to define odd_list as "Oklahoma"; that's just what the tests behind the scenes are doing to make sure your output is correct. You don't want to hard-code it. The challenge needs to run your code with a known input (the string "Oklahoma") to ensure that the expcted output is returned. Your code shouldn't specify that - the following is fine:

def first_4(a_list):
    return a_list[:4]

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

I hope that helps.

Steve.

Thank you Steve.

That helped a lot.