In the code below, I\'d like the while loop to exit as soon as a + b + c = 1000. However, testing with
while
a
b
c
1000
You could use a break statement:
a = 3 b = 4 c = 5 x = 0 while x != 1: for a in range(3,500): for b in range(a+1,500): c = (a**2 + b**2)**0.5 if a + b + c == 1000: print a, b, c print a*b*c break