Course Content
Python Loops Tutorial
Python Loops Tutorial
List & for Loop
We can employ various data structures when working with loops. So far, we've covered strings, and now we'll explore working with a list of numbers.
Examine the following code:
How does the code work?

To work with a decreasing list, you can utilize the reversed()
function. This function allows you to reverse the order of elements in a list, effectively turning it into a decreasing list.
How does the code work?

Task
To sum the elements inside the list, follow these steps:
- Configure the
for
loop to operate on thenumbers
, utilizingi
as an element of the list. - Calculate the sum by adding elements to the
counter
within the loop. - Print the value of the
counter
after the loop has completed.
Everything was clear?
Section 1. Chapter 4