2.3.2 The for Loop
The for loop is used to iterate over a sequence of elements.
It is commonly used with lists, ranges, and other iterable objects.
How the for Loop Works
- The loop variable takes each value from the sequence
- The loop body executes once for each element
- The loop ends when all elements are processed
Common Use Cases
- Iterating over lists or strings
- Processing ranges of numbers
- Looping through data collections
📌 Note:
Useforloops when the number of iterations is known or based on a sequence.