Description
Lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.).
Where to use
- Traversing complex data structures.
Real World Example
The 'foreach' loop in most languages. It works on Arrays, Lists, and Trees identically.
Code Example
class Iterator:
def __init__(self):
pass
def execute(self):
print('Executing Iterator')
