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

This challenge looks like it wants Oklahoma for some reason. Also, cannot pass the challenge, not sure if there is a bug

Seems like there may be a bug. I was able to pass it once, but now the 1st part is not parsing.

slices.py
def first_4(list):
  list = [1,2,3,4,5,6,7,8]
  return list[0:4]

def odds("O","k","l","a","h","o","m","a")
  return odds[1::2]

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

the correct solution is:

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

There're couple of problems in your solutions

  1. You should pass in a list to odds function as parameter, not a bunch of Strings.
  2. avoid using list as your variable name, because list is a predefined function in Python.
Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You don't need to define the values of the arguments to your functions (it actually won't even work the way you're doing it).