The following program works as expected. It first prints a string, then assigns 3 variables to 3 separate integers. With these integers, it checks if the third one is NOT equal to the first integer plus the second one. If the first two integers aren't equal to the third after being added together, the program prints all three integers out then repeats the assigning of the integers and continues until the first two are equal to the third integer added together. Ex: 6 + 6 = 12 OR 3 + 3 = 10
from __future__ import print_function
import random
print("HERE COMES THE DICE!")
r1 = random.randint(1,6)
r2 = random.randint(1,6)
total = r1 + r2
while r1 != r2:
r1 = random.randint(1,6)
r2 = random.randint(1,6)
total = r1 + r2
print("Roll #1: {}".format(r1))
print("Roll #2: {}".format(r2))
print("The total is {}!".format(total))
The problem I'm currently having with this program is how to shorten it by converting the while loop into a do-while loop. I have knowledge of the do-while loop in Java, but have none for the Python version.