For Loop in Python

While LoopLoop Control

The for loop is the most common way to repeat code when you know what you're looping over – like a list of items, characters in a string, or a range of numbers.

It's clean, readable, and very powerful for processing collections.

Unlike while, for loop doesn't need manual counter updates – it handles iteration automatically.

Basic For Loop with range()

range() generates a sequence of numbers. It's perfect for counting.

range(start, stop, step) – stop is exclusive.

Looping Over Lists

Directly iterate over list items – no index needed.

Looping Over Strings

Strings are sequences of characters – treat them like lists.

Looping Over Tuples and Dictionaries

Nested For Loops

A for loop inside another for loop – useful for grids, tables, or combinations.

for...else

else runs when the loop finishes normally (no break).

Quick Quiz

We have reviewed and checked the materials, but errors may still occur. The content is provided for educational purposes only, so use it at your own responsibility and verify with other sources if needed.

✨ Ask Lara — your AI study partner

Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.


Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.

Track Your Progress 🚀

Learn more easily by tracking your progress completely for free.