mardi 8 novembre 2016

Python randint not equal to 0 [duplicate]

This question already has an answer here:

I am trying to use random.randint to randomly generate a single int between a range, e.g. randint(-2,2), however, it could possibly generate 0, which is not expected, so I am wondering is there a way to make it not equal to 0. Or just use a loop until randint(-2,2) not generate 0, and get the output.

cheers




Aucun commentaire:

Enregistrer un commentaire