Python : Loops
Loops are used to execute a block of code repeatedly. There are two types of loops in Python:
For Loops in Python
A for loop is used to iterate over a sequence (such as a list, tuple, or string) and execute a block of code for each item in the sequence.
The syntax for a for loop in Python is:
for item in sequence: # code block to execute for each item
While Loops in Python
A while loop is used to execute a block of code repeatedly as long as a certain condition is true.
The syntax for a while loop in Python is:
while condition: # code block to execute while condition is true