To understand what a loop is, think of it as a continuous errand you send someone on until a condition is met or they complete the task they're doing. If you don't tell the person when to stop, they might just keep going!
The computer doesn't have a human brain that allows it to pause, look at you, and ask, "When should I stop running?" It doesn't get tired. It just keeps doing its work until you tell it to stop or the task is completed. A loop that never stops is called an infinite loop , and we’ll see how it can happen in the while loop section.
The two types of loops we'll look at are the for loop and the while loop.
The For Loop
Think of the for loop as a worker with a bag of items. You give him the bag because you're just too tired to go through it yourself.…