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 between min_val and max_val (inclusive) with a specified length n.
Technology Stack : random
Code Type : Generate random list
Code Difficulty : Intermediate
import random
def generate_random_list(n, min_val, max_val):
"""
Generate a list of random integers between min_val and max_val (inclusive) with length n.
"""
return [random.randint(min_val, max_val) for _ in range(n)]