course content

Course Content

Python Loops Tutorial

List & while LoopList & 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?


Calculate the sum of the squares of the numbers in the list.

  1. Initialize a while loop, using i as the index to iterate through the numbers.
  2. Accumulate the squares of the numbers into the counter to compute the sum.
  3. Display the value stored in the counter.

Everything was clear?

Section 2. Chapter 3
toggle bottom row