Is there a way to return an iterable object ? class twoTimes: def __init__(self, n): self.__n = n def getNext(): self.__n *= 2 return self.__n t = twoTimes(5) while (n in t.getNext()): # while (n in t): print (n) -- Anjanesh Lekshmnarayanan