14
Meniru loop do-while di Python?
Saya perlu meniru loop do-while dalam program Python. Sayangnya, kode langsung berikut ini tidak berfungsi: list_of_ints = [ 1, 2, 3 ] iterator = list_of_ints.__iter__() element = None while True: if element: print element try: element = iterator.next() except StopIteration: break print "done" Alih-alih "1,2,3, selesai", ia mencetak output berikut: …
799
python
while-loop
do-while