Python - Magic Methods and Operator Overloading
What will be the output of this code?
class MyIter:
def __init__(self):
self.n = 0
def __iter__(self):
return self
def __next__(self):
if self.n < 3:
self.n += 1
return self.n
else:
raise StopIteration
it = MyIter()
print(list(it))
print(list(it))