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 trialVadim Sh
2,037 PointsOops! It looks like Task 1 is no longer passing.
import random dir(random) def random_num x= input () y= random.randint(1,x) return y
import random
dir(random)
def random_num
x = input()
y = random.randint(1,x)
return y
1 Answer
Ryan Ruscett
23,309 PointsHey,
Yeah no you don't need to actually get any input It's coming to the method already. We just need to make sure our method can take something.
you got the import random but the dir? That will list the methods, but of course that's not important here. But if you do a dir(random) you will see all the available functions. It appears to have two. random.randint and random.randrange. Now I chose to do randrange because it includes the endpoints. Where as randint does not. I think either will pass the test though.
Like this.
import random
def random_num(num):
randint = random.randrange(1,num)
return randint #return it.
That's all you have to do. Now to answer the question as to why it says 1 is no longer passing. That is because it has an error. The challenges are a little funky in that step one checks to see if you have an import. Then step two looks to see if you have 1 and 2. So all I can ever determine about these is that you did something to break it. If the project wont compile at all, that it can't check task 1 for example.
Let me know if this helped you.