Home › Python with Chai › Lesson 5

for loops: try every flavour

Python with Chai, lesson 5 of 20. A short Hinglish video, simple English notes and code you can run, free.

Open the interactive lesson with Run button

The idea

With for f in flavours:, each item in the list goes into f, one at a time.

The code inside the loop runs once for each item.

Whether there are 4 items or 100, the code stays just as short.

The code

flavours = ["Masala", "Adrak", "Elaichi", "Tulsi"]

for f in flavours:
    print(f + " chai")

Output:

Masala chai
Adrak chai
Elaichi chai
Tulsi chai

Try it yourself

Remember

A for loop handles every item, one by one.

← Lists: all the flavours in one place · Dictionaries: the chai menu card →

All lessons: Python with Chai