jeudi 4 juillet 2019

How to output random.sample to a variable?

I'm trying to output random.sample to a list variable instead of printing it. I want to do this as I want to compare 2 lists.

All i can figure out is how to print it out

Code:

import random

num1 = int(input("Highest List Number in List 1: "))
num2 = int(input("Highest List Number in List 2: "))

list1 = range(num1)
list2 = range(num2)

print("1st List: ", random.sample(list1,k=10))
print("2nd List: ", random.sample(list2,k=10))

Can this be done with random.sample? If not can you advise another random module to try?




Aucun commentaire:

Enregistrer un commentaire