6 Repeating actions with loops
What you will learn
You know that programs work by receiving input data, doing something with it, and then producing an output. You also know how to use conditional statements to make programs respond to input in a sensible way. A program can test for values and other conditions and change what it does depending on what it finds. Up to this point, all the programs we’ve written run through their statements and then stop. However, you often need to make a program repeat a sequence of statements. For example, if a user enters an invalid value, you want the program to reject that value and repeat the sequence to request ...
Get Begin to Code with Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.