The loop that never ends · الحلقة التي لا تنتهي
The loop that never ends
Run this first and watch what happens. The line that makes count smaller is there — but it is outside the loop, so it never runs.
In Python the indentation is the structure: lines indented under while belong to the loop and repeat, a line back at the left margin comes after the loop and runs once at the end. Here the loop never reaches its last line, so its question stays true for ever. The page will notice and stop it for you, but your program should stop itself.
الحلقة التي لا تنتهي
شغّل هذا أولاً ولاحظ ما يحدث. السطر الذي يجعل count أصغر موجود — لكنه خارج الحلقة، لذا لن يعمل أبداً.
في بايثون، المسافة البادئة هي البنية: الأسطر المزاحة تحت while تنتمي للحلقة وتُكرر، والسطر الذي يعود هوامش اليسار يأتي بعد الحلقة ويعمل مرة واحدة في النهاية. هنا لا تصل الحلقة إلى سطرها الأخير، لذا يبقى سؤالها صحيحاً إلى الأبد. ستلاحظ الصفحة وتتوقف عنك، لكن برنامجك يجب أن يتوقف بنفسه.
Run this first and watch what happens. The line that makes count smaller is there — but it is outside the loop, so it never runs. Move it inside so the program prints 5, 4, 3, 2, 1 and stops. · شغّل هذا أولاً وشاهد ما يحدث. السطر الذي يجعل count أصغر موجود — لكنه خارج الحلقة، لذا لن يعمل أبدًا. انقله داخل الحلقة ليطبع البرنامج 5، 4، 3، 2، 1 ويتوقف.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.