How do I implement custom iterators so that I can nest them?
How do I implement custom iterators so that I can nest them? Question: I was just looking up some stuff about python iterators and stumbled across thisW3School iterator example example from w3school: class MyNumbers: def __iter__(self): self.a = 1 return self def __next__(self): if self.a <= 20: x = self.a self.a += 1 return x …