Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
221,295 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.