# How to Generate Random Integers Between 0 and 9 in Python?

## Problem –

You want to generate random integers between 0 and 9 (inclusive) in Python.

## Solution –

### Using random.randrange –

To generate random integers between 0 and 9, you can use random.randrange


In [1]: from random import randrange

In [2]: randrange(10)
Out[2]: 5

In [3]: randrange(10)
Out[3]: 5

In [4]: randrange(10)
Out[4]: 1

### Using random.randint –

You can also use random.randint

In [5]: from random import randint

In [6]: randint(0, 9)
Out[6]: 5

In [7]: randint(0, 9)
Out[7]: 1


Rating: 1 out of 5.