You can download this code by clicking the button below.
This code is now available for download.
This function receives a Sanic response object and a tuple representing the number range, then generates a random integer within that range. If number_range is not a tuple, the function will return an error message.
Technology Stack : Sanic, random
Code Type : Random number generator
Code Difficulty : Intermediate
def generate_random_number(response, number_range):
import random
if isinstance(number_range, tuple):
lower, upper = number_range
return random.randint(lower, upper)
else:
return "number_range must be a tuple with two integers"