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

Bummer! Did you create `random_num()`?

I am wondering what is wrong with my code, I am getting the above error about defining the function.

import random

def random_num(num): return randint(1, num)

random_num.py

1 Answer

Marileen Mennerich
Marileen Mennerich
1,161 Points

Make sure to use the imported random -> random.randint(1, num) Also, I am not sure because I haven't done this challenge yet, but usually they have several steps and go forward slowly. Could it be that in this step, they're asking for a function that does not take a parameter yet?

edit: Just did the challenge. Using random.randint(1,num) should do the trick, it worked for me.

Thanks, Marileen, I added the random part that was missing and now it works.