Index Ai Academy
Glossary · Phase 7 · Software engineering

Iterator

Also written: iterators

An object that gives the next item each time next() is called, and is used up when it runs out.

Try it now

Step through: the generator's body only runs when next() or list() asks for a value, and each yield pauses it with n still remembered.

Learn it properly

Iterators and generators · The iteration protocol, yield, lazy pipelines and itertools, in small memory. About 40 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write