Understanding loops (for and while) and how to use them
These are used to repeat a block of code for each item in a collection (like a list or string). It’s useful when you know in advance how many times you want to repeat the code.
These repeat a block of code as long as a specific condition remains true. They are useful when you don’t know in advance how many times the loop should run. The loop continues until the condition becomes false.
Loops are essential for automating repetitive tasks in your programs. For instance, a loop can go through a list of student names and print them out one by one.