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
Hemos revisado y comprobado los materiales, pero aún pueden existir errores. El contenido se ofrece únicamente con fines educativos, así que úsalo bajo tu propia responsabilidad y verifica con otras fuentes si es necesario.
✨ Pregunta a Lara — tu compañera de estudio con IA
Desbloquea soporte de aprendizaje personalizado. Lara puede explicar lecciones, resumir temas y responder tus preguntas — disponible desde el plan Go y superiores.
Lara te ayuda a aprender más rápido — exclusivo para los miembros ReadyTools Go, Plus y Max.

