Python Loop Iterator
Iterator မှတဆင့်လှည့်ပတ်ခြင်း။
for
ထပ်ကာထပ်ကာ ပြုလုပ်နိုင်သော အရာဝတ္ထုတစ်ခုမှတဆင့် ထပ်ဆင့်ပြန်ဆိုရန် ကွင်းပတ် တစ်ခုကိုလည်း အသုံးပြုနိုင်သည် ။
ဥပမာ
tuple ၏တန်ဖိုးများကို ထပ်လောင်းဖော်ပြသည်-
mytuple = ("apple", "banana", "cherry")
for x in mytuple:
print(x)
ဥပမာ
စာကြောင်းတစ်ခု၏ အက္ခရာများကို ထပ်လုပ်ပါ-
mystr = "banana"
for x in mystr:
print(x)
loop သည် အမှန်တကယ် တွင် for
iterator object တစ်ခုကို ဖန်တီးပြီး loop တစ်ခုစီအတွက် next() method ကို လုပ်ဆောင်သည်။