Python: Generate a random integer between Min and Max

Last updated on October 29, 2020 A Goodman Loading... Post a comment

To generate a random integer between two given integers, you can use the randint method of the random module.

Example

import random

print(random.randint(0, 100))
print(random.randint(-100, 100))
print(random.randint(200, 500))

Hope this helps 🙂

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Related Articles