While Loops
<Python>Bài 8: While Loops
Tạo file: bai8.py
i = 0 numbers = [] #kiểm tra i < 6 thì thực hiện while i < 6: print "At the top i is %d" % i numbers.append(i) # chèn vào list numbers i = i + 1 # tăng giá trị i lên 1 để vòng lặp có thể kết thúc
print "Numbers now: ", numbers #in ra các giá trị trong list
print "At the bottom i is %d" % i # in ra giá trị hiện tại của i print "The numbers: " for num in numbers: print num
Kết quả:
Chúc các bạn thành công!
No Comment to " While Loops "