Starlit Daily

📚 › Python: the friendliest first language

8. Loops with for and range

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

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.

عرض المثال

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

✍️ دورك الآن

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

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