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.

Hi,

I really don't get what's wrong with my code..

Error message: It looks like Task 1 is no longer passing

Thanks for Help.

random_num.py
import random

def random_num(rd1)
   return random.randint(1, rd1)

1 Answer

Take a look here for a good discussion of this challenge.

Thanks for your help Cena! It's so logic =) The variable rd1 in my function is undefined, i have to give the variable first a value!

Cheers!

The only problem I had with your code in the challenge is that the function is missing a colon.

import random

def random_num(rd1):  # added a colon here
   return random.randint(1, rd1)

With this change, the code passes.