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 trialShadow Skillz
3,020 PointsNow make a function named random_num that takes an int argument. Return a randint between 1 and the passed-in number
Not sure where I'm messing up at
import random
def random_num(n1,n2):
return randint(1,10)
Robert Richey
Courses Plus Student 16,352 PointsSorry about that, randint is a method from the random class. We need to call it as follows:
import random
def random_num(n1):
return random.randint(1, n1)
Shadow Skillz
3,020 PointsThanks again Robert it worked I really appreciate that.
1 Answer
Robert Richey
Courses Plus Student 16,352 PointsHi Christian,
Your function is accepting two arguments - it should only accept one argument. When calling randint(), use 1 and the passed in variable to your function as the arguments to randint().
import random
def random_num(n1):
return randint(1, n1)
Shadow Skillz
3,020 PointsShadow Skillz
3,020 Pointsthanks for the help but for some reason I'm still getting an error