Welcome to the Treehouse Community
Looking to learn something new?
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 Parker215,939 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.