Can you create a large list with random numbers?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answer ( 1 )
#creating a large list in python using random numbers
#assuming random numbers to fall between 1 to 100 and integers
import random #library to generate random numbers
randlist = [] #creating an empty list
for i in range(0, 1000): #for loop for generating random numbers and appending the list
n = random.randint(1, 100)
randlist.append(n)
print(“the list generated with random numbers is n”, randlist)