jeudi 7 mai 2015

Generate random number X where X % Y = 0

I am interested in only a selection of random number ,
in this case X % 5 == 0.

from random import randint
num = randint(5,15000) #Inclusive
while not (num % 5 == 0):
    num = randint(5,15000)
print num

here is what I have so far, but this does not seem like it's very pythonic.
Any suggestions?

Thanks




Aucun commentaire:

Enregistrer un commentaire