Challenge 1: An Evens-Only Iterator — Possible Solution ==================================================================== class EvensUpTo: def __init__(self, limit): self.limit = limit self.current = 0 def __iter__(self): return self def __next__(self): if self.current > self.limit: raise StopIteration value = self.current self.current += 2 return value for n in EvensUpTo(10): print(n) Output: 0 2 4 6 8 10 WHY THIS WORKS AS AN ANSWER ------------------------------ __init__(self, limit) stores the upper bound and starts self.current at 0 — the starting point for counting up through even numbers, using the plain instance-attribute pattern from Course 2, Chapter 1. __iter__(self): return self reuses the chapter's own Countdown pattern exactly — EvensUpTo is its own iterator, so calling iter() on an instance just returns that same instance, which already has __next__ defined. __next__(self) reuses the chapter's own raise StopIteration structure: once self.current exceeds self.limit, StopIteration is raised, signaling the for loop to stop, exactly the mechanism described in this chapter's "unrolled for loop" example. Before that point, it captures the current value, advances self.current by 2 (skipping the odd numbers entirely, rather than checking every number and filtering — a cleaner approach than generating every integer and testing n % 2 == 0), and returns the captured value. Because 0, 2, 4, 6, 8, 10 are all <= the limit of 10, the loop produces all six of them; the seventh call to __next__ would find self.current (12) greater than self.limit (10) and raise StopIteration, ending the for loop cleanly — the same automatic StopIteration handling the chapter's own for n in Countdown(3): example relies on.