Iterator
say it: “IT-uh-ray-ter” /ˈɪtəreɪtər/
Gives out items one at a time with next() and remembers where it is.
What is an iterator?
An iterator gives out items one at a time with next() and remembers where it is. A for loop uses one behind the scenes.
line = iter(["Ana", "Ben", "Cai"])
print(next(line)) # Ana
print(next(line)) # Ben
Level: Freelancer · More Python terms at this level
Updated