Python Python Basics (2015) Letter Game App Random Item

What's the answer and please explain

This problem doesn't make a whole lot of sense to me can you please help.

item.py
import random 

def random_item(arg):
    arg = [
    'life'
    'love'
    'live'
    'learn'
    'eat'
    'pray'
    'enjoy'
    'happy']:
    randomization.len(arg)
    n = random.randict(1,len(arg))
        return arg[n-1]
# EXAMPLE
# random_item("Treehouse")
# The randomly selected number is 4.
# The return value would be "h"# EXAMPLE
# random_item("Treehouse")
# The randomly selected number is 4.
# The return value would be "h"

1 Answer

Steven Parker
Steven Parker
177,931 Points

I left you a number of hints when you asked about this same challenge a couple of days ago. Perhaps the most important one is that you won't need to provide any data. Your function will need to use what is provided to it in "arg" so you don't want to overwrite it with a new assignment.

Another hint I gave before was that the "random" class has no "randict" property. You probably meant to use "randint" instead.

Then, there's two other issues:

  • the line with "randomization" causes an undefined reference and doesn't seem to be part of the process
  • the "return" line seems to be indented too far

One you take care of all these, you should be good to go.