From the course: Programming Foundations: Beyond the Fundamentals
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Iterating to a custom endpoint - Python Tutorial
From the course: Programming Foundations: Beyond the Fundamentals
Iterating to a custom endpoint
- Screwing something in is fundamentally an iterative process. To tighten down the C clamp, I need to get it in place, do a turn to the right and check if it's tight. It's not. It's still loose. So I need to reposition my hand, give it another turn and check again. and I need to just keep doing that until it's tight. Only at that point do I stop my loop. This type of iteration doesn't rely on a collection of things to iterate through, like say folding laundry. Instead, it's simply something that needs to happen repeatedly until it's done. In the same way, sometimes when I'm writing code I need to continue a loop until the program arrives at a certain state. In Python you use a while statement to create this type of loop. To get started with a while loop we commonly use a variable that will be modified on each iteration through the loop. The name doesn't matter but you'll often see the variable name i, which is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.