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

Course Content

Python Loops

Python Loops

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

bookSimple 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

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 1
toggle bottom row

bookSimple 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

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 1
toggle bottom row

bookSimple 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

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

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

Task

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 1
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt