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 trialMatt Song
2,971 PointsHow do you do this challenge?
I am looking for the directions, but I am unsure how to proceed. Some help, please?
1 Answer
AJ Salmon
5,675 PointsHiya Matt!
This one can be hard to understand. Here's what the challenge asks you to do:
- Import the random library.
- Create the function and set the parameter, it will be given one argument: an iterable object.
- Generate a random number with random.randint() that can range between 0 and 1 less than the length of the iterable passed to the argument. Hint: you'll need to use len().
- Return the item from the iterable that has the same index as the random number.
Hopefully this is enough help, but if you need more, feel free to ask :)
jonlunsford
16,746 Pointsjonlunsford
16,746 PointsHere's how I would solve it: