Welcome to the Treehouse Community
Looking to learn something new?
Thananjaya Chakravarthy4,672 Points
how to return the iterable member specified by means of index, that is been selected by the random.randint.
clearly don't know, how to execute the program...
# EXAMPLE # random_item("Treehouse") # The randomly selected number is 4. # The return value would be "h" import random def random_item(name): start=random.randint(0,len(name)-1) while True:
Stuart Wright41,102 Points
Your first 3 lines are correct. Then after that you simply need to return the item at the random index you've chosen using the random number generator:
import random def random_item(name): start = random.randint(0, len(name)-1) return name[start]