Starlit Daily

📚 › Python: the friendliest first language

9. while loops

ستتم ترجمة هذا المقال تلقائيًا. يُعرض بالإنجليزية حاليًا.

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.

عرض المثال

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

✍️ دورك الآن

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

← العودة إلى الدورة