From the course: Programming Foundations: Real-World Examples

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

For loops

For loops - Python Tutorial

From the course: Programming Foundations: Real-World Examples

Start my 1-month free trial

For loops

- Loops are programming constructs which repeatedly perform an operation or series of operations over and over and over. There are two types of loops, for loops and while loops. One of the key differences between them is that with a for loop, you know exactly how many times that loop is going to perform its operation before it even runs. Some languages do this by creating a variable that will count up to a certain value and for loops can also be used to iterate through items in a list. That list will have a certain number of items which will be the number of times the for loop executes. With a while loop, you don't know how many times a loop is going to be executed. Instead, as the loop is running, it's constantly checking and checking for a condition to determine whether or not it should execute one more time. I'll use loops to help me perform a complex operation that I'm very familiar with, doing the dishes. My kitchen is a little bit of a mess and I want to clean it up before my…

Contents