Count down in twos
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · עמוד זה דורש דפדפן עדכני (תומך ב-SharedArrayBuffer). אנא עדכן את Chrome, Edge, Firefox או Safari לגרסה העדכנית ביותר.
This one builds on a lesson you haven't finished yet. Do that lesson first: · תרגיל זה מתבסס על שיעור שעדיין סיימת. סיים את השיעור תחילה:
Python Basics · בסיסי Python · While loops →
Count down in twos
n starts at 10. Print 10, 8, 6, 4, 2 using a while loop.
The step does not have to be 1. Check where it stops: from 10 taking 2 each time, the value after 2 is 0, and 0 > 0 is false — so 0 is never printed.
n starts at 10. Print 10, 8, 6, 4, 2 using a while loop.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.