I have the following code:
while True:
if var_p1 != "0":
break
else:
import random
var_p1 = random.randint(-5,5)
I want the loop to repeat until var_p1
equals anything but zero. However, I get zero all the time. What am I doing wrong?
Best Answer
Answering the question in the title, not the real problem (which was answered by Daniel Roseman):
How do you create a random range, but exclude a specific number?
Using
random.choice
: