Python · Generators & Iterators
What does this print, and why is defining iteration this way convenient? class Countdown: def __init__(self, n): self.n = n def __iter__(self): for i in range(self.n, 0, -1): yield i print(list(Countdown(3)))
Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.
