There is no need for a function or a generator. A for() loop is a unique case of a while loop ## for i in range(-10.5, 10.5, 0.1): ctr = -10.5 while ctr < 10.5: print ctr ctr += 0.1