Skip to content
Advertisement

Why does Python not read the next line (if)?

I wrote the program about Pythagorean I got my answer but python doesn’t read (break) after (if) . My program title : (Special Pythagorean triplet), there is a one answer exist for ((a+b+c=1000)&(a**2 + b**2 =c**2) ) I want find abc . I know (a=200, b=375, c=425) but when program starts it never stop and it continue. It also types the product of these three numbers.

JavaScript

Advertisement

Answer

There’s no need for the pyth variable. You can just use return True or return False.

The if statement needs to be indented so it’s in the loop.

You need to test the value of the function call.

You don’t need else: continue. Loops automatically continue unless you break out of them. continue is only needed when you want to skip the rest of the loop body and start the next iteration; it’s not needed at the end of the body.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement