Liftoff · การทะลุวงโคจร
Liftoff
Count down from 5 to 1, then print Liftoff!.
A while loop repeats as long as its condition is true, so something inside the loop must change the variable, or the loop never stops. Code written after the loop, without indentation, runs once when the loop ends.
Liftoff
นับถอยหลังจาก 5 ถึง 1, แล้วพิมพ์ Liftoff!
ลูป while จะทำซ้ำจนกว่าเงื่อนไขจะเป็นเท็จ ดังนั้นสิ่งที่อยู่ภายในลูปต้องมีการเปลี่ยนแปลงตัวแปร มิฉะนั้นลูปจะไม่หยุดทำงาน โค้ดที่เขียน หลัง ลูป โดยไม่มีการย่อบรรทัด จะถูกรันเพียงครั้งเดียวเมื่อลูปสิ้นสุด
Use a while loop to count down from 5 to 1, one number per line, then print Liftoff!. · ใช้ while ลูปนับถอยหลังจาก 5 ถึง 1 บรรทัดละหนึ่งเลข แล้วพิมพ์ Liftoff!
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่