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 trialMUZ140249 Sibusisiwe Dube
2,900 Pointschallenge task 2of 2 for stage 6 : Pick a number! any number
Now make a function named random_num that takes an int argument. Return a randint between 1 and the passed-in number.
import random
1 Answer
Geoff Parsons
11,679 Pointsif you look at the python documentation for random you'll see that random.randint
takes two arguments:
random.randint(a, b)
Return a random integer N such that a <= N <= b.
This will make your life pretty easy as you can just pass 1 and the number that was passed to your random_num
method directly in and return the result.
Hope this helps get you on the right track.