From the course: Programming Concepts for Python
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
For loops - Python Tutorial
From the course: Programming Concepts for Python
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 the 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…