How can I generate random integers between 0 and 9 (inclusive) in Python?
For example, 0, 1, 2, 3, 4
0
1
2
3
4
The secrets module is new in Python 3.6. This is better than the random module for cryptography or security uses.
To randomly print an integer in the inclusive range 0-9:
from secrets import randbelow print(randbelow(10))
For details, see PEP 506.