Generate random integers between 0 and 9
This is more of a mathematical approach but it works 100% of the time:
Let's say you want to use random.random() function to generate a number between a and b. To achieve this, just do the following:
num = (b-a)*random.random() + a;
Of course, you can generate more numbers.
How can I generate random integers between 0 and 9 (inclusive) in Python?
For example, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9