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 trialMatthew Casey
825 PointsWhy doesnt this work my dudes?
import random
def random_item(item): new_iterable = random.randint(0, len(item) -1) return new_iterable
2 Answers
Steven Parker
229,785 PointsDUDE! You might be returning the wrong thing.
Well, you forgot to include a link to your challenge. But since you're picking a random number based on the length of the argument, I'm going to guess you wanted to return an item from that argument.
So instead of returning the number itself, you may want to return the item at that index ("item[new_iterable]
").
Matthew Casey
825 PointsSorry, not really sure how to use these. So you'd return: return ("item[new_iterable]") ??
Steven Parker
229,785 PointsSteven Parker
229,785 PointsIf my guess is correct, you would:
return item[new_iterable]
But I can't be certain that's what you need without seeing the challenge itself.