In the code below, I'd like the while loop to exit as soon as a + b + c = 1000. However, testing with print statements shows that it just continues until the for loops are done. I've tried while True and then in the if statement set False but that results in an infinite loop. I thought using x = 0 and then setting x = 1 might work but that too just runs until the for loops finish. What is the most graceful and fastest way to exit? Thanks.
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
x = 1
cis floating, but it didn't seem to matter. The program finds ana+b+c=1000so apparently doesn't care about1000vs1000.0. Good to know though because it could be an issue at times.