Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialannikaheflin
577 PointsWhat's the answer and please explain
This problem doesn't make a whole lot of sense to me can you please help.
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
231,248 PointsI 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.