Nameerror: Name 'Random' Is Not Defined [Closed]
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...
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
You have to import the module random:
import random
r = random.randint(1,10)
# ...
>>> import random
>>> r = random.randint(1,10)
>>> r
10
you need to import the random library with the import keyword
import random
random.randint(1,10) #no. between 0 and 10