Python Random randint() Method
Example
Return a number between 3 and 9 (both included):
import random
print(random.randint(3, 9))
Try it Yourself »
Definition and Usage
The randint() method returns an integer
number selected element from the specified range.
Note: This method is an alias for randrange(start, stop+1).
Syntax
random.randint(start, stop)
Parameter Values
| Parameter | Description |
|---|---|
| start | Required. An integer specifying at which position to start. |
| stop | Required. An integer specifying at which position to end. |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.