Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Simple For Loops | For Loops
Python Loops
course content

Conteúdo do Curso

Python Loops

Python Loops

1. While Loops: Get Started
2. While Loops: Essentials
3. For Loops
4. Nested Loops

Simple For Loops

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 1
toggle bottom row

Simple For Loops

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 1
toggle bottom row

Simple For Loops

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Tarefa

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 1
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt