How do I generate a random number from a specific set of digits? For example,
I want to generate numbers from the range 1-100,000
such that every number has only odd digits (for example: 111
, 1351
, 19711
etc..)
Using the random module I tried:
import random
rand = random.randint([1, 3, 5, 7, 9])
Is there any efficient way of doing it?
Thank you.
Aucun commentaire:
Enregistrer un commentaire