Starlit Daily

📚 › Python: the friendliest first language

8. Loops with for and range

Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.

A for loop goes through each item of a sequence. range(5) produces 0, 1, 2, 3 and 4: it starts at zero and stops before 5.

range(1, 6) gives 1 to 5.

Ver ejemplo

for n in range(1, 4):
    print("Count", n)

✍️ Ahora te toca

Print the numbers 1 to 5, one per line, using range.

← Volver al curso