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

Contenu du cours

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.

Tâche

Swipe to start coding

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

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 6. Chapitre 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.

Tâche

Swipe to start coding

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

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 6. Chapitre 4
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt