For Loop in Python
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
Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.
✨ Frag Lara — deine KI-Lernpartnerin
Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.
Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.

