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 trialMUZ140927 George Chingore
2,647 PointsI dont see whats wrong with my code (Now make a function named random_num that takes an int argument...)
I keep getting an error that says "can't seem to call random_num()
with an argument."
import random
list = [1,2,3,4,5]
def random_num(list):
return random.randint(1, len(list)-1)
2 Answers
Chris Adamson
132,143 PointsThe challenge is looking for a number to be passed in, not a list:
import random
def random_num(num):
return random.randint(1, num)
Dan Johnson
40,533 PointsThe argument being passed in is an int representing the upper range of the random number. Getting rid of the call to len should help.
You also won't need to define any input to be passed in. The challenge will deal with that.
MUZ140927 George Chingore
2,647 PointsGreat! it worked.Thanks guys.