Hi,

I'm trying to make a program that is based on random selections but whenever I run the random function in idle i get an error, can anyone explain to me what I'm doing wrong?

>>> randint(1,9)

Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
randint(1,3)
NameError: name 'randint' is not defined
>>>

you have to import the module that contains that function first:

>>> import random
>>> random.randint(1,3)
1

Jeff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.