Generate random integers using Python randint()

In this article, we’ll take a look at generating random integers using the Python randint() method.

This method is in the random module in Python, which we will use to generate pseudo-random numbers, so we’ll need to import it to load this method. Let’s take a look at this method now!


Syntax of Python randint()

The Python randint() method returns a random integer between two limits lower and upper(inclusive of both limits). So this random number could also be one of the two limits.

We can call this function as follows:

random_integer = random.randint(lower, upper)

Here, lower is the lower limit of the random number, and upper is the upper limit of the random number.

We must ensure that lower and