demo_iterator2.py:
mystr = "banana" myit = iter(mystr) print(next(myit)) print(next(myit)) print(next(myit)) print(next(myit)) print(next(myit)) print(next(myit))
➜ begtut>python demo_iterator2.py
b
a
n
a
n
a