Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyIterator:
- def __init__(self, start, end):
- self.start = start
- self.end = end
- self.current = self.start
- def __iter__(self):
- return self
- def __next__(self):
- if self.current >= self.end:
- raise StopIteration()
- else:
- self.current += 1
- return self.current - 1
- my_iterator = MyIterator(1, 11)
- for num in my_iterator:
- print(num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement