Loops
This lesson will introduce loops in Python.
We'll cover the following
Why loops?
Many times, during programming, we have to repeat the same task a number of times. For instance, we have a list of numbers and we want to double every number in it. Here, we want to perform the same task for every item on our list. This is where loops come in handy. Loops are used to execute the same block of code a fixed number of times.
There are two kinds of loops in Python.
- The
for
loop - The
while
loop
Get hands-on with 1400+ tech skills courses.