Patrick Patrick - 1 month ago 7
Python Question

Generate random integers between 0 and 9

How can I generate random integer numbers between 0 and 9 (inclusive) in Python?

i.e. 0 1 2 3 4 5 6 7 8 9

Answer

Try:

from random import randint
print(randint(0,9))

More info: https://docs.python.org/3.1/library/random.html#random.randint

Comments