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 trialKelly Ferrell
2,561 PointsI don't know what is wrong with my return.
I don't know why my return wont work. I tried indenting it and then undenting it. This is driving me crazy. Please help.
import random
my_list = [1,2,3,4,5]
def random_member(my_list):
random_num = random.randint(0,(len(my_list) -1)
return my_list[random_num]
3 Answers
Barnabas Abraham
8,297 PointsHi Kelly,
I would check the amount of brackets you have on this line:
random_num = random.randint(0,(len(my_list) -1)
Looks like it's missing a closing bracket there.
Charles Lee
17,825 PointsYou're missing a ending parenthesis in your random_member function.
def random_member(my_list):
random_num = random.randint(0,(len(my_list) -1)) # <-- Here
return my_list[random_num]
Kelly Ferrell
2,561 PointsThanks for the update. It worked. Thanks again.