dimanche 28 avril 2019

How to generate random numbers with given length of input to add and multiply

I'm trying to generate 2 lists of random numbers between 1 to 10 and trying to do an user input for how many numbers they want to generate per list. Then I'm trying to figure out how to add and multiply the 2 lists together.

The problem is that I feel like I know how to make all this happen separately but I can't seem to figure out how to put them together using main()

for example : i import random then create a blank list for the random generator to put numbers into the empty list, but I don't know how to create an easy way for the user input the number in for the length of the list.

import random

myList = []

for i in range(1,11):
    x = random.randint(1, 10)
    myList.append(x)


print(myList)

input("Amount of numbers preferred in a list: ")   <---- not sure where to put this and add more code to be part of the generating process.




Aucun commentaire:

Enregistrer un commentaire