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

What's Kaoa

Mr. KenLove im stuck on the kaoa, i dont get wat kaoa is and how it is odd

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

def odds(numodd):
  numodd = list(range(8))
  return(numodd[1::2])
def first_4(arg):     # the sequence argument
  return arg[:4]      # the slice starts at 0 to 4 less 1, sequences start at 0 :)


def odds(arg):
  y = [arg[index] for index in range(len(arg)) if not index%2==0]  # learning to use list comprehensions
  return ''.join(y)                                                             # join the list to a string


def first_and_last_4(arg): 
  return arg[:end_index] + arg[start_index:]  # adding the list gives me a list inclusive of the first and last

2 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Zvisinei.

"kaoa" is what your function is returning.

The code challenge has the word "Oklahoma" as the default iterable when it checks your code. The error message provides you with the returning output so that you can understand what is going wrong.

Also, please note that you only need to return the slice as requested byt the code challenge, no need to declare a list variable.

Vittorio

thanx got it to work