Python - Magic Methods and Operator Overloading
Identify the error in this iterator implementation:
class MyIter:
def __init__(self):
self.data = [1, 2, 3]
self.index = 0
def __iter__(self):
return self
def __next__(self):
if self.index <= len(self.data):
result = self.data[self.index]
self.index += 1
return result
else:
raise StopIteration