Python Random randrange() Method
Example
Return a number between 3 and 9:
import random
print(random.randrange(3, 9))
Try it Yourself »
Definition and Usage
The randrange()
method returns a randomly selected element from the specified range.
Syntax
random.randrange(start, stop, step)
Parameter Values
Parameter | Description |
---|---|
start | Optional. An integer specifying at which position to start. Default 0 |
stop | Required. An integer specifying at which position to end. |
step | Optional. An integer specifying the incrementation. Default 1 |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.