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 trialAlex Jones
851 PointsCode works in workspace but when I run it in the task area it says "Oops! It looks like Task 1 is no longer passing"
Challenge Task 2 of 2
Now make a function named random_num that takes an int argument. Return a randint between 1 and the passed-in number.
import random
userInput = input()
def random_num(intArg1):
print(random.randint(1, int(intArg1)))
random_num(userInput)
1 Answer
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Adam
you dont need to print the random number generated nor do you need to call the function.
import random
def random_num(myInt):
return random.randint(1,int(myInt))
Alex Jones
851 PointsAlex Jones
851 PointsThanks Andreas!
Blair Owens
8,235 PointsBlair Owens
8,235 PointsI'm curious how I should have got this answer. Don't recall learning that in the previous lessons.
deborahwyatt
1,297 Pointsdeborahwyatt
1,297 PointsFor some reason, this is not working for me. Is it a glitch in the system?
The return actually is at the same level as the def statement. This does work in Workspaces. Am I misunderstanding what the question is?