I want to use random.uniform to generate a float in between say [-2, 2], but not generate 0, this is how I do it in a loop,
from random import uniform
flag = True
while flag:
if uniform(-2, 2) is not 0:
flag = False
I am wondering is there better way to do it?
cheers
Aucun commentaire:
Enregistrer un commentaire