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
Section 6. Chapter 4
single

single

for loop (2/5)

Swipe to show menu

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)

Or over list

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

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
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt