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 trial

Python Python Basics (Retired) Pick a Number! Any Number! Imports

Kelly Ferrell
Kelly Ferrell
2,561 Points

I 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.

random_num.py
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

Hi 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.

You'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
Kelly Ferrell
2,561 Points

Thanks for the update. It worked. Thanks again.