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

The exercise is asking me if I've made a "random_num()" function, but I think I did.

Can you see what I may be doing wrong when you look at this code? Thank you.

random_num.py
import random

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

Never ye mind, apparently, it wanted me to call my random integer "int"

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

I take that back, it didn't work.

This is my error message: " Bummer! Did you create random_num()?"

2 Answers

You're almost there. All you need to do is call the randint function from the random library.

import random

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

AhhH! Thanks so much!