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
Sue Dough
35,800 PointsNothing I do passes :( I keep reading indent on the forums and can't figure it out.
Hi I can't figure it out. I did some searching in the forums and none of the answers seem to work for me.
import random
def random_num(a_list):
a_list=[1,2,3,4,5]
random_num = randint(0,(len(a_list)-1))
return a_list[random_num]
2 Answers

Luke Glazebrook
13,564 PointsHere is the right code.
import random
def random_num(thisIsInt):
randomNum = random.randint(1, thisIsInt)
return randomNum

Luke Glazebrook
13,564 PointsHi!
Try un-indenting your whole function so it is on the same level as your import. After that, try indenting all of the code after the function call and that should work great for you!

Sue Dough
35,800 PointsLike this? Can you please paste the proper code?
import random
def random_num(a_list):
a_list=[1,2,3,4,5]
random_num = randint(0,(len(a_list)-1))
return a_list[random_num]
Sue Dough
35,800 PointsSue Dough
35,800 PointsYou rock Luke.
Luke Glazebrook
13,564 PointsLuke Glazebrook
13,564 PointsThank you!
Keep up the good work.