Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
450 B
1
Indexable
Never

Copy code
class LimitationIterator:
    def __init__(self, start, limit):
        self.start = start
        self.limit = limit

    def __iter__(self):
        return self

    def __next__(self):
        if self.start <= self.limit:
            result = self.start
            self.start += 5
            return result
        else:
            raise StopIteration

# Using the iterator
it = LimitationIterator(5, 89)
for num in it:
    print(num)
Leave a Comment