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

Now make a function named random_num that takes an int argument. Return a randint between 1 and the passed-in number.

I can't get past this step. For some reason, it is not accepting my code, and I am sure it is correct unless I am misunderstanding the instructions. Someone please help.

random_num.py
import random
def random_num(anum):
return random.randint(1, anum)

2 Answers

Hanley Chan
Hanley Chan
27,771 Points

Hi,

You just need to indent your code inside your function random_num

Thank you. I was thinking the return should be on the same level as the def. SMH.