Many times happened to me that I was coding 3 or 4 nested loops, the problem is that with the break
statement, I could only skip one of the loops and the rest of those would continue to proceed...
Is there anyway to break all of the nested loops?
ex:
a = 3
b = 4
c = 5
while a <= 333:
b = a + 1
while b <= 500:
c = 1000 - a - b
while c < 500:
if c**2 == (a**2) + (b**2) and a + b + c = 1000:
print("this is the first number : ", a)
print("this is the second number : " ,b)
print("and this is the third number : " ,c)
break
else :
c +=1
b +=1
a +=1
print(a)
It's the code I have written for Project Euler #9!
when the condition of if statement is met... how can I stop those while loops from running?