Python Python Basics (2015) Letter Game App Random Item

gurinder singh
PRO
gurinder singh
Pro Student 1,422 Points

why it's saying that (random_item) is not defined?

I defined it.

item.py
# EXAMPLE
# random_item("Treehouse")
# The randomly selected number is 4.
# The return value would be "h"
import random

def random_item (treehouse):
    result = random.randit(0, len(treehouse) -1)
    return treehouse[result]

1 Answer

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Gurinder,

There's a small typo causing the function to fail. random.randit should be random.randint.

I hope this helps.