Stop at the first over fifty · Berhenti pada yang pertama melebihi lima puluh
Stop at the first over fifty
n starts at 1. Keep adding 1 to it. As soon as n * n is more than 50, leave the loop with break. Print n afterwards.
break leaves the loop at once. ⚠️ It only works inside the loop, so the if that holds it must be indented under the while too — and the break indented once more, under the if. print(n) stays at the left, outside the loop, so it runs after the break.
Berhenti saat melebihi fifty pertama kali
n dimulai dari 1. Terus tambahkan 1 ke dalamnya. Segera setelah n * n melebihi 50, keluar dari loop dengan break. Cetak n afterwards.
break keluar dari loop segera. ⚠️ Ini hanya berfungsi di dalam loop, jadi if yang menahannya juga harus disisipkan di bawah while — dan break disisipkan satu tingkat lagi, di bawah if. print(n) tetap di margin kiri, di luar loop, sehingga berjalan setelah break.
n starts at 1. Keep adding 1 to it. As soon as n * n is more than 50, leave the loop with break. Print n afterwards. · n dimulai dari 1. Terus tambahkan 1 ke dalamnya. Segera setelah n * n melebihi 50, keluar dari loop dengan break. Cetak n afterwards.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.