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
Tony Brackins
28,766 PointsNow make a function named random_num that takes an int argument. Return a randint between 1 and the passed-in number.
Hello,
Can anyone help with this?
What I have now, which I know is wrong :(
import random
passed_in_number = 1
def random_num(passed_in_number): return random.randit(1,passed_in_number)
6 Answers
Kenneth Love
Treehouse Guest TeacherAlso make sure the body of your function is indented.
boog690
8,987 PointsYou spelled "randint" as "randit."
Aman Kumaran
2,314 Pointspython is kinda tricky it seems.
Kenneth Love
Treehouse Guest TeacherIts not really tricky, but it is very precise.
Aman Kumaran
2,314 Pointsyeah, will practice more on it :)
MUZ140082 mucheni
1,244 Pointsam also confused about how to mak a function named random_num
Vladimir Vladimirovich
Courses Plus Student 614 PointsTry something like this: import random def random_num (num): return random.randrange(1, num)