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
Stuck on this one. I have tried 3 different (VERY SIMILAR) variations of the attached code/screenshot and am not getting it solved. I am thinking the problem is that the 'return'?
# EXAMPLE # random_item("Treehouse") # The randomly selected number is 4. # The return value would be "h" import random def random_item(num): random.randint(0, len(num - 1)) return(random.randint)
Steven Parker228,025 Points
Yes, partly. You want to return an element from the iterable. But to do that, when you call randint (the first time) you will need to save the value it returns in a variable. Then you can use that variable as an index to select an item from the iterable.