Python

Important Statements

The for Loop

Iterates over the elements of an iterable (like lists, tuples, strings, ranges). Used when you know how many times you want to loop or are processing items in a collection.

for variable in iterable:
    # Code to execute for each item in the iterable
    statement_1
    statement_2
    # ...

The while Loop

Executes a block of code repeatedly as long as a condition is true. Used when the number of iterations is not known beforehand.

while condition:
    # Code to execute while condition is True
    statement_a
    statement_b
    # ...

Loop Control Statements

These statements change the flow of execution within loops.