Python iter() လုပ်ဆောင်ချက်
ဥပမာ
ထပ်ကာထပ်ကာ အရာဝတ္ထုတစ်ခုကို ဖန်တီးပြီး အရာများကို ပရင့်ထုတ်ပါ-
x = iter(["apple", "banana", "cherry"])
print(next(x))
print(next(x))
print(next(x))
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
iter()
function သည် iteration object တစ်ခုကို ပြန်ပေးသည် ။
အထားအသို
iter(object, sentinel)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
object | Required. An iterable object |
sentinel | Optional. If the object is a callable object the iteration will stop when the returned value is the same as the sentinel |
ဆက်စပ်စာမျက်နှာများ
reversed() function သည် reversed iterator object ကို ပြန်ပေးသည်။