lundi 17 février 2020

Having unique random numbers in more than one variables

Is it possible to have more than one variables and each have a unique and distinct random number from one another. The sample range is the same, yet I do not want the variables to have same numbers.

import random

A=random.sample(range(1,4),1)
B=random.sample(range(1,4),1)
C=random.sample(range(1,4),1)

So the above example, I want A, B and C to have different random numbers. In other words, no two variables must have the same number.

How to go about this?




Aucun commentaire:

Enregistrer un commentaire