So I wrote this function to generate a list of numbers between start
and stop
(inclusively) at step
interval:
start, stop, step, = -3, 3, 0.1
print [x * step + start for x in range(int((stop + step - start) / step))]
print 12 * 0.1 + -3
the output was:
[1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7000000000000002, 1.8, 1.9, 2.0]
1.7
why is the list messing up 1.7, but when I do the same operation outside the for loop, it works just fine? How do I fix the for loop?