Python random.randint() function can generate an integer random number. In this tutorial, we will tell you somethings you must notice when using this function.
random.randint(start, end)
The value of result is in [start, end]
For example:
import random r = random.randint(0,2)
Variable r may be 0, 1 or 2.
start and end should be integer.
For example:
import random r = random.randint(1.1,2) print(r)
Then you will get error:
ValueError: non-integer arg 1 for randrange()