Here is my code:
r = random.randint(1,10)But for some reason it's giving me the error
NameError: name 'random' is not defined
Other info: Mac, Python, 3.4.0 pylauncher
3 Answers
You have to import the module random:
import random
r = random.randint(1,10)
# ... 0 >>> import random
>>> r = random.randint(1,10)
>>> r
10 1 you need to import the random library with the import keyword
import random
random.randint(1,10) #no. between 0 and 10 2