fork download
  1. # while_loop.py (Python 2.7)
  2. counter = 0
  3. maks = 5
  4.  
  5. while counter < maks:
  6. print "Perulangan ke:", counter
  7. # lakukan sesuatu setiap iterasi (mis. cek input dari web/id.one)
  8. # if check_input(): handle_input() # pseudocode
  9. counter += 1
  10.  
  11. print "Selesai loop while."
Success #stdin #stdout 0.02s 7256KB
stdin
Standard input is empty
stdout
Perulangan ke: 0
Perulangan ke: 1
Perulangan ke: 2
Perulangan ke: 3
Perulangan ke: 4
Selesai loop while.