dimanche 3 octobre 2021

A random integer between specific values excluding 0

I have to generate a random integer i between a chosen minimum and chosen maximum value, which I have written as follows:

min = -10
max = 10
i = random.randint(min, max)

The problem is that I don't know how to exclude the number zero.

I need to exclude 0 because later on I'll be dividing min/max, so min can't be zero and max can't be as well (cause you'll get a zero modulo error).




Aucun commentaire:

Enregistrer un commentaire