Python Python Basics (2015) Letter Game App Random Item

I keep getting a "Bummer! NameError: name 'random_item' is not defined" error in a challenge

The challenge is

The only occurrence of 'random_item' on the page is a default example which is commented out - I removed this but the same error appears. Even after clearing all data from the challenge code box, then attempting to check answer again, the same error is displayed.
# random_item("Treehouse")
# The randomly selected number is 4.
# The return value would be "h"
import random

def random_int(iterable):
    random_letter = random.randint(0, len(iterable) - 1)
    return iterable[random_letter]

1 Answer

Steven Parker
Steven Parker
170,377 Points

It's not Python that's complaining but the challenge.

The instructions say "create a function named random_item" but your function is named "random_int" instead.

Doh! Nice spot Steven :-) Working now, cheers