How do I set the range to be between two randomized numbers in Python? [closed]

21 hours ago 1
ARTICLE AD BOX

The issue you will run into with the random bounds is the sorted nature. You can address that at runtime by taking the min and max of the range:

import random def random_number_from_random_range(min_bound=1, max_bound=999): a = random.randint(min_bound, max_bound) b = random.randint(min_bound, max_bound) low, high = sorted((a, b)) number = random.randint(low, high) return number, low, high

answered 2 hours ago

Kartik's user avatar

Sign up to request clarification or add additional context in comments.

Comments

Read Entire Article