This is a very simple dice roll program that keeps rolling two dice until it gets double sixes. So my while statement is structured as:
while DieOne != 6 and DieTwo != 6:
For some reason, the program ends as soon as DieOne
gets a six. DieTwo
is not considered at all.
But if I change the and
to an or
in the while statement, the program functions perfectly. This doesn't make sense to me.
import random
print('How many times before double 6s?')
num=0
DieOne = 0
DieTwo = 0
while DieOne != 6 or DieTwo != 6:
num = num + 1
DieOne = random.randint(1,6)
DieTwo = random.randint(1,6)
print(DieOne)
print(DieTwo)
print()
if (DieOne == 6) and (DieTwo == 6):
num = str(num)
print('You got double 6s in ' + num + ' tries!')
print()
break