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

Python Python Basics (Retired) Pick a Number! Any Number! Imports

Shadow Skillz
Shadow Skillz
3,020 Points

Now 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

random_num.py
import random
def random_num(n1,n2):
    return randint(1,10)
Shadow Skillz
Shadow Skillz
3,020 Points

thanks for the help but for some reason I'm still getting an error

Sorry 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
Shadow Skillz
3,020 Points

Thanks again Robert it worked I really appreciate that.

1 Answer

Hi 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)