Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
List & while Loop | The while Loop
Python Loops Tutorial
course content

Contenido del Curso

Python Loops Tutorial

Python Loops Tutorial

1. The for Loop
2. The while Loop
3. Nested Loops

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:

1234567
numbers = [1, 2, 4, 5, 7] i = 0 # Printing all elements from the list while i < len(numbers): print(numbers[i]) i += 1
copy

How does the code work?

Tarea

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.

Tarea

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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 3
toggle bottom row

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:

1234567
numbers = [1, 2, 4, 5, 7] i = 0 # Printing all elements from the list while i < len(numbers): print(numbers[i]) i += 1
copy

How does the code work?

Tarea

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.

Tarea

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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 3
toggle bottom row

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:

1234567
numbers = [1, 2, 4, 5, 7] i = 0 # Printing all elements from the list while i < len(numbers): print(numbers[i]) i += 1
copy

How does the code work?

Tarea

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.

Tarea

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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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:

1234567
numbers = [1, 2, 4, 5, 7] i = 0 # Printing all elements from the list while i < len(numbers): print(numbers[i]) i += 1
copy

How does the code work?

Tarea

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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 3
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt