I'm trying to get used to list comprehensions, but I struggle with this- How can I assign random integers to several values at a time?
My solution is this:
a,b,c=random.sample(100, 3)
But when I run code it gives me error:
TypeError: Population must be a sequence or set. For dicts, use list(d).
I think there shoud be solution to avoid simply repeating this three times like:
a=random.randint(0,99)
b=random.randint(0,99)
c=random.randint(0,99)
Aucun commentaire:
Enregistrer un commentaire