# ------------------------------------------------------------------------- # # --- Loops --------------------------------------------------------------- # # # Looping constructs are available in the form of while and do-while # statements. The while statement checks the condition before each # iteration: i = 0; while i < 10: i = i + 1; # This loop runs for 10 times. As for the if-else statement, a single # statement is expected as the body of the while statement. You can # provide it a compound statement tho. i = 0; while i < 10: { print('While iteration no. ', i, '\n'); i = i + 1; } # The do-while statement checks the condition at the end of each # iteration. This means that at least one iteration is performed! i = 0; do { print('Do-while iteration no. ', i, '\n'); i = i + 1; } while i < 10; # Like for if-else statements, variables defined inside the loop # body are shared with the parent's context. # # ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #