How to generate a random list of numbers from 0 to 100 in Python?

You can use the randint() function from the random library to generate random integers from 0 to 100, and then add these integers to a list. Here is an example code:

import random

random_list = [random.randint(0, 100) for _ in range(10)]
print(random_list)

This code will generate a list of 10 random integers between 0 and 100. You can modify the parameters of the range() function as needed to generate lists of different lengths.

bannerAds