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!

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

Matthew Casey
Matthew Casey
825 Points

Why 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
Steven Parker
224,924 Points

:point_right: DUDE! 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]").

Steven Parker
Steven Parker
224,924 Points

If 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.

Matthew Casey
Matthew Casey
825 Points

Sorry, not really sure how to use these. So you'd return: return ("item[new_iterable]") ??