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!
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
Andy Hitchings3,351 Points
Hi - what is the answer for this please? I am stuck. Thanks,
Python Basics - code challenge task2/2 - imports.py
Winnie E Tibingana21,066 Points
For challenge two please ensure:
- The function has to take a list as argument.
- Create the list with some data say *my_list *
- Create the random numbers using random.randint
- Return the number
As shown below:
import random my_list=[1,2,3] #thanks for correct Jason def random_member(my_list): random_num = random.randint(0,(len(my_list)-1)) return my_list[random_num]
Hope this helps
return random.randint(1, num)