i made this algorithm that tells you if a number is prime but i don’t understand why the if-else statement is on different levels

The code is using a for-else clause, not an if-else clause!

for blah:
    do stuff
    do more

The do more clause is executed if and only if you exit the for loop normally, i.e. without raising an error or using a break statement.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top