Course Content
Python Loops Tutorial
Python Loops Tutorial
List & while Loop
We've already integrated lists into for
loops.
To interact with the list now, we'll require one crucial function: len(list)
. This function provides the list's length.
Don't fret; you'll grasp it!
Examine the code below:
How does the code work?
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a8aeafab-f546-47e9-adb6-1d97b2927804/2_3_fskdds.gif)
Task
Calculate the sum of the squares of the numbers in the list.
- Initialize a
while
loop, usingi
as the index to iterate through thenumbers
. - Accumulate the squares of the numbers into the
counter
to compute the sum. - Display the value stored in the
counter
.
Everything was clear?
Section 2. Chapter 3
Course Content
Python Loops Tutorial
Python Loops Tutorial
List & while Loop
We've already integrated lists into for
loops.
To interact with the list now, we'll require one crucial function: len(list)
. This function provides the list's length.
Don't fret; you'll grasp it!
Examine the code below:
How does the code work?
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a8aeafab-f546-47e9-adb6-1d97b2927804/2_3_fskdds.gif)
Task
Calculate the sum of the squares of the numbers in the list.
- Initialize a
while
loop, usingi
as the index to iterate through thenumbers
. - Accumulate the squares of the numbers into the
counter
to compute the sum. - Display the value stored in the
counter
.
Everything was clear?
Section 2. Chapter 3