Welcome to the Treehouse Community
Looking to learn something new?
Kade Carlson5,928 Points
Not sure what to return
Not sure how I should code this
# EXAMPLE # random_item("Treehouse") # The randomly selected number is 4. # The return value would be "h" import random def random_item('apple'): random.randint(0, len('apple') - 1) return
Thomas Harris7,647 Points
Hello! When your random_item() function takes an argument, that's the variable to use and you have to pass a string to it. Then your return value should be the variable passed to it, but only the one letter referenced by the random index "i"
Should look like this:
import random def random_item(item): i = random.randint(0, len(item) - 1) return item[i] print(random_item('apple'))