LLD Logo
LVL1
Iterator Pattern

Step 1 of 4 · Define Iterator and Iterable roles

1

Your task

Define Iterator and Iterable roles

Separate the traversal contract from collections that can be traversed.

Represent a book with its title.
Define hasNext, next, and current on Iterator.
Define createIterator on Iterable.

iterator_contracts.py

Your draft · saved locally

1

Structural feedback only—your code stays in this browser and is not executed.