For Loop in Python

While ciklusCiklusvezérlés

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

Az anyagokat átnéztük és ellenőriztük, de hibák továbbra is előfordulhatnak. A tartalom kizárólag oktatási célt szolgál, ezért saját felelősségre használd, és szükség esetén ellenőrizd más forrásokkal is.

✨ Kérdezd Larát — a tanulási partnered

Fedezd fel a személyre szabott tanulási támogatást. Lara elmagyarázza az anyagot, összefoglalja a témákat és megválaszolja a kérdéseidet — az Go csomagtól elérhető.


Lara segít gyorsabban tanulni — kizárólag a ReadyTools Go, Plus és Max tagoknak.

Kövesd nyomon a fejlődésed 🚀

Tanulj egyszerűbben utad nyomonkövetésével teljesen ingyen.