Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

I am having a problem with this exercise. I get the message, "Bummer! Did you create random_num()" -- but the instructio

I am having a problem with this exercise. I get the message, "Bummer! Did you create random_num()" -- but the exercise calls for the function to accept an argument of type int. How am I supposed to get the function random_num() -- which accepts no arguments to accept one argument?

import random
def random_num():
  return randint(1,number)

2 Answers

Dan Johnson
Dan Johnson
40,532 Points

Despite the error message random_num should take a single argument. The issue you were probably running into was not specifying the module for randint:

random.randint(1, number)

Dan, thanks for answering. I did forget to call the module for randint. The help messages for the Challenge seem to be out of sync with the actual problem. The response from the Challenge "Check Work" when I attempt to submit the answer with the missing modules asks me if I created "rand_num()" -- which is the wrong approach. Does someone need to fix the message given by the Challenge in this case?

Dan Johnson
Dan Johnson
40,532 Points

I'll go ahead and tag Kenneth Love and see if he agrees on updating the function signature in the error message, or adding a reminder about referencing the randint function through the random module.