Home >>Python Random Module >Python Random randrange() Method

Python Random randrange() Method

Python Random randrange() Method

Python Random randrange() Method in python is used to returns a selected elements randomly from the specified range(start, stop, step).

Syntax:
random.randrange(start, stop, step)

Parameter Values

Parameter Description
start It is Optional and is used at which position to start, its default value is 0.
stop It is Required and is used at which position to end.
step It is Optional and is used to specify the incrementation their default value 1.
Here is an example of Python Random randrange() Method:

import random
print(random.randrange(5, 14))

Output:
10
Example 2:

import random
print(random.randrange(12, 22))

Output:
12

No Sidebar ads