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

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?

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

2 Answers

Dan Johnson
Dan Johnson
40,533 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,533 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.