Please explain what I'm doing wrong?
I am not really sure what I am doing right or wrong I haven't been coding for 14 days oops. Please help.
import random def random_item[ 'life' 'love' 'live' 'learn' 'eat' 'pray' 'enjoy' 'happy']: random.randint(0 < 8) random.randict - 1 return random.randict # EXAMPLE # random_item("Treehouse") # The randomly selected number is 4. # The return value would be "h"
Steven Parker177,888 Points
Here's a few hints:
- when defining a function, the name must be followed by parentheses with the parameter(s) inside
- you won't need to provide any data, the challenge will do that itself
- the "randint" function takes two arguments separated by a comma
- you'll need to use the length of the argument to get a random number in the right range
- the "random" class has no "randict" property
- the return value needs to be selected from the incoming argument
Hopefully this breaks down the steps for you
- random_item function needs an argument for iterable. syntax looks like: def func_name(arg):
- need to evaluate how many items are in this iterable to set the range for randomization. len(arg)
- determine random number. n=random.randint(1, len(arg))
- return the result. return arg[n-1]