I have the following code to create a list of numbers starting at 0.05, ending at 1.25, every 0.05 step.
intervals = [0.05]
point = 0.05
while len(intervals) < 25:
point = point + 0.05
intervals.append(point)
print(intervals)
However, the result is the follwing list:
[0.05, 0.1, 0.15000000000000002, 0.2, 0.25, 0.3, 0.35, 0.39999999999999997, 0.44999999999999996, 0.49999999999999994, 0.5499999999999999, 0.6, 0.65, 0.7000000000000001, 0.7500000000000001, 0.8000000000000002, 0.8500000000000002, 0.9000000000000002, 0.9500000000000003, 1.0000000000000002, 1.0500000000000003, 1.1000000000000003, 1.1500000000000004, 1.2000000000000004, 1.2500000000000004]
Python seems to randomly add/substract certain decimals. How can I obtain the following desired list:
[0.05. 0.1, 0.15, 0.20, 0.25, 0.30, 0.40, ......1.20, 1.25]
What am I doing wrong?
Thanks!