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 trialNick Nahimana
591 PointsBummer! Did you create `random_num()`?
I am wondering what is wrong with my code, I am getting the above error about defining the function.
import random
def random_num(num): return randint(1, num)
1 Answer
Marileen Mennerich
1,161 PointsMake sure to use the imported random -> random.randint(1, num) Also, I am not sure because I haven't done this challenge yet, but usually they have several steps and go forward slowly. Could it be that in this step, they're asking for a function that does not take a parameter yet?
edit: Just did the challenge. Using random.randint(1,num) should do the trick, it worked for me.
Nick Nahimana
591 PointsNick Nahimana
591 PointsThanks, Marileen, I added the random part that was missing and now it works.