class Squares: def __init__(self, start, stop): self.value = start - 1 self.stop = stop def __iter__(self): return self def next(self): if self.value == self.stop: raise StopIteration self.value += 1 return self.value ** 2for i in Squares(1, 5): print i,
Name (required)
email (will not be published) (required)
Website