Course Content
Python Loops Tutorial
Python Loops Tutorial
Range() in a for Loop 2/2
Note
We will often use the
counter
variable in our tasks to perform simple math operations.For example, if we want to add 2 and 3, we need to create the
counter
, setcounter = 0
, and then add 2 and 3 to thecounter
:counter = 0 + 2 + 3 = 5
=>counter = 5
.We should use this kind of variable, or we won't be able to handle the implementation of simple math operations.
Look at the code below:
How does the code work?

Task
We learned an example of adding elements from 50 to 100. We did that with the increasing list. Now we need to remake the task for the decreasing list.
- Set a
for
loop, usingi
as an element of the range and setting step = -1. - Implement the sum by adding elements inside the range.
- Print the
counter
.
Everything was clear?
Section 1. Chapter 3