February 13th, 2004, 07:11 AM
Random Number Generating (Whole numbers)
I am using the following code and am getting errors thrown at me, but I can't understand why?
from random import Random, random
num = random.randint(10,20)
End of code.
The error is saying that I can't import name random? So obviously the error lies on line 1.
Can anyone see what might be causing this error?
February 13th, 2004, 07:45 AM
It seems that it was my file name that was causing the problem (random.py).
I am still getting an error, though. Through the same code as in the previous post, I am getting the folowing error message...
'function' object has no attribute 'randint'
Anyone see where I am going wrong?
February 13th, 2004, 09:32 AM
Try this instead:
num = random.randint(10, 20)
from random import randint
num = randint(10, 20)
Last edited by Scorpions4ever; February 13th, 2004 at 09:35 AM.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
February 17th, 2004, 10:45 AM
Cheers, the second section of code works fine.