實作 iter 和 next。
class Counter: def __init__(self, max): self.max = max self.current = 0 def __iter__(self): return self def __next__(self): if self.current >= self.max: raise StopIteration self.current += 1 return self.current