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 trialRicardo Rodriguez
9,758 PointsExpected output (stage 2 on slices) is "kaoa"? Where exactly does “kaoa” comes from?
I just executed my code for task 2 on SLICES and I the result says: "Bummer! odds()
didn't return the right output. Got [1, 3, 5, 7, 9], expected kaoa"
I honestly thought expected output was [1, 3, 5, 7, 9] so code is doing what I wanted to do but maybe I’m not understanding the question. Where exactly does “kaoa” comes from?
def first_4(i):
eliter = list(range(10))
return(eliter[1:5])
def odds(i):
eliter = list(range(10))
return(eliter[1::2])
5 Answers
boog690
8,987 PointsOklahoma is the input, let's call it state. The letters at odd indexes (1, 3, 5, 7) in state spell "kaoa".
Ricardo Rodriguez
9,758 PointsOh..., that worked. Where in instructions did I missed that "Oklahoma" was the input?.. strange.. but thanks.
boog690
8,987 PointsWell, I just assumed it was "Oklahoma" from the "kaoa." The input can be anything. The function should always return the letters (concatenated as a string) at the odd indices of any word.
Ricardo Rodriguez
9,758 Pointsawesome thanks.
Kenneth Love
Treehouse Guest TeacherYou're taking arguments, i
in both cases, and then completely ignoring them :) Don't ignore your arguments!
Ricardo Rodriguez
9,758 PointsThank you so much Kenneth.
Amanda Flagg
1,716 PointsI agree with the original poster here, I was also just using numbers in this code challenge because nothing about the prompt states to use "Oklahoma." Might want to have that added to the prompt. This is what it says currently:
"Make a function named odds that accepts an iterable as an argument and returns the items with an odd index in the iterable."
Kenneth Love
Treehouse Guest TeacherAdding "Oklahoma" to prompt makes it really easy to fake the output if someone really wanted to cheat the validator. Also, strings are iterables just like lists and dicts and tuples are. The function should be able to handle any and all iterables.
Amanda Flagg
1,716 PointsAhh, that makes a lot of sense Kenneth. I didn't think about the possibility of cheating the validator.
It's easy enough to figure out if your function is handling iterables, but at first I was confused as to why there wasn't a hint as to what string the validator was looking for if it wanted such a specific return value. Thanks for the persecptive!