Python · Generators & Iterators
What does this print? class Count: def __init__(self, n): self.n, self.i = n, 0 def __iter__(self): return self def __next__(self): if self.i >= self.n: raise StopIteration self.i += 1 return self.i c = Count(2) for a in c: for b in c: print(a, b)
Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.
