How do I generate a random number?
This is my code:
from random import randint print randint(1, 10) #will print a random number between 1 and 9(inclusive)
or you can just:
import random print random.randint(1, 10) #will print a random number between 1 and 9(inclusive)
Hope this helps
Not to be confused with
randrange which excludes the stop value,
randint includes both the low and the high arguments. That is,
randint( a , b )
Return a random integer N such that
a <= N <= b.