You can download this code by clicking the button below.
This code is now available for download.
This function generates a list of random integers within a specified range.
Technology Stack : random
Code Type : Function
Code Difficulty : Intermediate
import random
def generate_random_list(size, min_value, max_value):
"""
Generate a list of random integers within a specified range.
:param size: int, the number of elements in the list
:param min_value: int, the minimum value in the range
:param max_value: int, the maximum value in the range
:return: list, a list of random integers
"""
return [random.randint(min_value, max_value) for _ in range(size)]