Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn for loop (2/5) | Loops
Learn Python from Scratch
course content

Course Content

Learn Python from Scratch

Learn Python from Scratch

1. The basics
2. Arithmetic operations
3. Common data types
4. Conditional statements
5. Other data types
6. Loops
7. Functions

book
for loop (2/5)

Remember data types we learned previously? for loop can easily iterate over some of them. For example, you can easily iterate over a string to get all symbols from it.

1234
# iterate over string s = "small string" for i in s: print(i)
copy

Or over list

1234
# iterate over list l = [1, [2,3], 4, "wow"] for i in l: print(i)
copy

The same applies to tuples.

Task

Swipe to start coding

Given list people. Using for loop, extract every single item from it.

Solution

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Β 6. ChapterΒ 4
toggle bottom row

book
for loop (2/5)

Remember data types we learned previously? for loop can easily iterate over some of them. For example, you can easily iterate over a string to get all symbols from it.

1234
# iterate over string s = "small string" for i in s: print(i)
copy

Or over list

1234
# iterate over list l = [1, [2,3], 4, "wow"] for i in l: print(i)
copy

The same applies to tuples.

Task

Swipe to start coding

Given list people. Using for loop, extract every single item from it.

Solution

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Β 6. ChapterΒ 4
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt