Intro to While Loops in Python
Do you know the difference between indefinite and definite iterations? In this lesson you’ll learn, that the while
-loop is an example of an indefinite iteration whereas the for
-loop is an example of a definite iteration. Furthermore, the characteristics of an indefinite iteration are revealed: They run forever until a certain condition is met.
00:00
Hey! This is Katie from Real Python. In this series of videos, you’re going to learn about the Python while
loop, or indefinite iteration.
00:07 So, if you’re familiar with coding or programming, you’ve probably seen something similar to this. Basically, it gives us a way to execute or iterate over a block of code multiple times. Whenever I say iteration, there’s actually two types: indefinite iteration and definite iteration.
00:25
Indefinite iteration is going to run forever until a condition is met. Our while
loop is an example of indefinite iteration, so while this condition returns True
, I’m going to print "hello"
, or execute this block of code. Definite iteration, however, is going to run as many times as indicated in the code.
00:43
So our for
loop is saying to print i
for however many i
’s there are in a
. In this series, you’re going to focus on indefinite iteration, which is the while
loop.
00:54
You’re going to learn about the structure and use of the Python while
loop, how to break out of a loop, and lastly, explore infinite loops.
01:02
In the next video, we’re going to start with the basic structure of a Python while
loop. Hope to see you there!
Become a Member to join the conversation.
lewiuberg on Dec. 1, 2019
Hi! Fyi, this course didn’t show up when I searched for “while” :)