Starlit Daily

📚 › Python: the friendliest first language

9. while loops

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

A while loop repeats as long as its condition is True. Change the variable inside the loop, or the loop never stops.

Use while when you do not know in advance how many times to repeat.

Ver ejemplo

count = 1
while count <= 3:
    print(count)
    count += 1

✍️ Ahora te toca

Use a while loop to print 2, 4, 6 on separate lines, starting with n = 2.

← Volver al curso