+ 1
What can I do to solve this error
class myNumbers: def __iter__(self): self.a = 1 return self def __next__(self): x = self.a self.a += 1 return x myclass = myNumbers() myiter = iter(myclass) print(next(myiter)) print(next(myiter)) print(next(myiter)) print(next(myiter)) print(next(myiter))
2 Answers
+ 7
You haven't added a space character as said by š®š³Omkarš
That's the reason it's causing the indentation error!
+ 4
Add one space character before
def __next__(self):
Python requires same amount of indentation for statements in same code block.
https://www.freecodecamp.org/news/indentation-in-python/



