vendredi 24 avril 2015

How do you create a random range, but exclude a specific number?

I have the piece of code:

while True:
    if var_p1 != "0":
        break
    else:
        import random
        var_p1 = random.randint(-5,5)

In theory, this should repeat until the variable equals anything but zero however, I still get zero all the time. What am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire