1a
Add an __iter__ method to Countdown. Then run c = Countdown(3) and print iter(c) is c.
Hint 1
The slide Iteration Protocol says what __iter__ returns when the object is its own iterator.
Hint 2
iter(c) is c asks whether __iter__ gives back the very same object.
Check your output
TrueShow solutionHide solution
class Countdown:
def __init__(self, start):
self.count = start
def __iter__(self):
return self
c = Countdown(3)
print(iter(c) is c)