How do I make a loop that prints only when variable "alice" equals zero and restarts the loop when variable "alice" does not equal zero?

My program is designed to print either y or z depending on what the computer chooses, but only if Alice equals zero, and if Alice does not equal zero, I want it to run the loop again and again until Alice does equal zero. Basically, I want the loop to keep running until both y and z are the same. What ends up happening instead is a number is printed even when Alice does not equal zero (i.e. when z and y are not the same). Why is this happening and how can I amend this issue?

alice = 0
while (alice == 0):
        y = random.randint(1,10)
        z = random.randint(1,10)
        alice = abs(y - z)
        elect = random.choice([y, z])

Read more here:

Content Attribution

This content was originally published by Charles Conklin at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: