Python 3.8.3 Calculation errors

The following code is giving decimal errors in Python version 3.8.3

def makelist(start, stop, increment):
value = start
result =
while value <= stop:
result.append(value)
value = value + increment
return result

mylist = makelist(0, 100, 0.2)
print(mylist)

#end result:
[0, 0.2, 0.4, 0.6000000000000001, 0.8, 1.0, 1.2, 1.4, 1.5999999999999999, 1.7999999999999998, 1.9999999999999998, 2.1999999999999997, 2.4, 2.6, 2.8000000000000003, 3.0000000000000004, 3.2000000000000006, 3.400000000000001, 3.600000000000001, 3.800000000000001, 4.000000000000001, 4.200000000000001, 4.400000000000001, 4.600000000000001, 4.800000000000002, 5.000000000000002, 5.200000000000002, 5.400000000000002, 5.600000000000002, 5.8000000000000025, 6.000000000000003, 6.200000000000003, 6.400000000000003, 6.600000000000003, 6.800000000000003, 7.0000000000000036, 7.200000000000004, 7.400000000000004, 7.600000000000004, 7.800000000000004, 8.000000000000004, 8.200000000000003, 8.400000000000002, 8.600000000000001, 8.8, 9.0, 9.2, 9.399999999999999, 9.599999999999998, 9.799999999999997, 9.999999999999996, 10.199999999999996, 10.399999999999995, 10.599999999999994, 10.799999999999994, 10.999999999999993, 11.199999999999992, 11.399999999999991, 11.59999999999999, 11.79999999999999, 11.99999999999999, 12.199999999999989, 12.399999999999988, 12.599999999999987, 12.799999999999986, 12.999999999999986, 13.199999999999985, 13.399999999999984, 13.599999999999984, 13.799999999999983, 13.999999999999982, 14.199999999999982, 14.39999999999998, 14.59999999999998, 14.79999999999998, 14.999999999999979, 15.199999999999978, 15.399999999999977, 15.599999999999977, 15.799999999999976, 15.999999999999975, 16.199999999999974, 16.399999999999974, 16.599999999999973, 16.799999999999972, 16.99999999999997, 17.19999999999997, 17.39999999999997, 17.59999999999997, 17.79999999999997, 17.999999999999968, 18.199999999999967, 18.399999999999967, 18.599999999999966, 18.799999999999965, 18.999999999999964, 19.199999999999964, 19.399999999999963, 19.599999999999962, 19.79999999999996, 19.99999999999996, 20.19999999999996, 20.39999999999996, 20.59999999999996, 20.799999999999958, 20.999999999999957, 21.199999999999957, 21.399999999999956, 21.599999999999955, 21.799999999999955, 21.999999999999954, 22.199999999999953, 22.399999999999952, 22.59999999999995, 22.79999999999995, 22.99999999999995, 23.19999999999995, 23.39999999999995, 23.599999999999948, 23.799999999999947, 23.999999999999947, 24.199999999999946, 24.399999999999945, 24.599999999999945, 24.799999999999944, 24.999999999999943, 25.199999999999942, 25.39999999999994, 25.59999999999994, 25.79999999999994, 25.99999999999994, 26.19999999999994, 26.399999999999938, 26.599999999999937, 26.799999999999937, 26.999999999999936, 27.199999999999935, 27.399999999999935, 27.599999999999934, 27.799999999999933, 27.999999999999932, 28.199999999999932, 28.39999999999993, 28.59999999999993, 28.79999999999993, 28.99999999999993, 29.19999999999993, 29.399999999999928, 29.599999999999927, 29.799999999999926, 29.999999999999925, 30.199999999999925, 30.399999999999924, 30.599999999999923, 30.799999999999923, 30.999999999999922, 31.19999999999992, 31.39999999999992, 31.59999999999992, 31.79999999999992, 31.99999999999992, 32.19999999999992, 32.39999999999992, 32.59999999999992, 32.799999999999926, 32.99999999999993, 33.19999999999993, 33.399999999999935, 33.59999999999994, 33.79999999999994, 33.99999999999994, 34.199999999999946, 34.39999999999995, 34.59999999999995, 34.799999999999955, 34.99999999999996, 35.19999999999996, 35.39999999999996, 35.599999999999966, 35.79999999999997, 35.99999999999997, 36.199999999999974, 36.39999999999998, 36.59999999999998, 36.79999999999998, 36.999999999999986, 37.19999999999999, 37.39999999999999, 37.599999999999994, 37.8, 38.0, 38.2, 38.400000000000006, 38.60000000000001, 38.80000000000001, 39.000000000000014, 39.20000000000002, 39.40000000000002, 39.60000000000002, 39.800000000000026, 40.00000000000003, 40.20000000000003, 40.400000000000034, 40.60000000000004, 40.80000000000004, 41.00000000000004, 41.200000000000045, 41.40000000000005, 41.60000000000005, 41.800000000000054, 42.00000000000006, 42.20000000000006, 42.40000000000006, 42.600000000000065, 42.80000000000007, 43.00000000000007, 43.200000000000074, 43.40000000000008, 43.60000000000008, 43.80000000000008, 44.000000000000085, 44.20000000000009, 44.40000000000009, 44.600000000000094, 44.8000000000001, 45.0000000000001, 45.2000000000001, 45.400000000000105, 45.60000000000011, 45.80000000000011, 46.000000000000114, 46.20000000000012, 46.40000000000012, 46.60000000000012, 46.800000000000125, 47.00000000000013, 47.20000000000013, 47.400000000000134, 47.600000000000136, 47.80000000000014, 48.00000000000014, 48.200000000000145, 48.40000000000015, 48.60000000000015, 48.80000000000015, 49.000000000000156, 49.20000000000016, 49.40000000000016, 49.600000000000165, 49.80000000000017, 50.00000000000017, 50.20000000000017, 50.400000000000176, 50.60000000000018, 50.80000000000018, 51.000000000000185, 51.20000000000019, 51.40000000000019, 51.60000000000019, 51.800000000000196, 52.0000000000002, 52.2000000000002, 52.400000000000205, 52.60000000000021, 52.80000000000021, 53.00000000000021, 53.200000000000216, 53.40000000000022, 53.60000000000022, 53.800000000000225, 54.00000000000023, 54.20000000000023, 54.40000000000023, 54.600000000000236, 54.80000000000024, 55.00000000000024, 55.200000000000244, 55.40000000000025, 55.60000000000025, 55.80000000000025, 56.000000000000256, 56.20000000000026, 56.40000000000026, 56.600000000000264, 56.80000000000027, 57.00000000000027, 57.20000000000027, 57.400000000000276, 57.60000000000028, 57.80000000000028, 58.000000000000284, 58.20000000000029, 58.40000000000029, 58.60000000000029, 58.800000000000296, 59.0000000000003, 59.2000000000003, 59.400000000000304, 59.60000000000031, 59.80000000000031, 60.00000000000031, 60.200000000000315, 60.40000000000032, 60.60000000000032, 60.800000000000324, 61.00000000000033, 61.20000000000033, 61.40000000000033, 61.600000000000335, 61.80000000000034, 62.00000000000034, 62.200000000000344, 62.40000000000035, 62.60000000000035, 62.80000000000035, 63.000000000000355, 63.20000000000036, 63.40000000000036, 63.600000000000364, 63.80000000000037, 64.00000000000037, 64.20000000000037, 64.40000000000038, 64.60000000000038, 64.80000000000038, 65.00000000000038, 65.20000000000039, 65.40000000000039, 65.60000000000039, 65.8000000000004, 66.0000000000004, 66.2000000000004, 66.4000000000004, 66.6000000000004, 66.80000000000041, 67.00000000000041, 67.20000000000041, 67.40000000000042, 67.60000000000042, 67.80000000000042, 68.00000000000043, 68.20000000000043, 68.40000000000043, 68.60000000000043, 68.80000000000044, 69.00000000000044, 69.20000000000044, 69.40000000000045, 69.60000000000045, 69.80000000000045, 70.00000000000045, 70.20000000000046, 70.40000000000046, 70.60000000000046, 70.80000000000047, 71.00000000000047, 71.20000000000047, 71.40000000000047, 71.60000000000048, 71.80000000000048, 72.00000000000048, 72.20000000000049, 72.40000000000049, 72.60000000000049, 72.8000000000005, 73.0000000000005, 73.2000000000005, 73.4000000000005, 73.6000000000005, 73.80000000000051, 74.00000000000051, 74.20000000000051, 74.40000000000052, 74.60000000000052, 74.80000000000052, 75.00000000000053, 75.20000000000053, 75.40000000000053, 75.60000000000053, 75.80000000000054, 76.00000000000054, 76.20000000000054, 76.40000000000055, 76.60000000000055, 76.80000000000055, 77.00000000000055, 77.20000000000056, 77.40000000000056, 77.60000000000056, 77.80000000000057, 78.00000000000057, 78.20000000000057, 78.40000000000057, 78.60000000000058, 78.80000000000058, 79.00000000000058, 79.20000000000059, 79.40000000000059, 79.60000000000059, 79.8000000000006, 80.0000000000006, 80.2000000000006, 80.4000000000006, 80.6000000000006, 80.80000000000061, 81.00000000000061, 81.20000000000061, 81.40000000000062, 81.60000000000062, 81.80000000000062, 82.00000000000063, 82.20000000000063, 82.40000000000063, 82.60000000000063, 82.80000000000064, 83.00000000000064, 83.20000000000064, 83.40000000000065, 83.60000000000065, 83.80000000000065, 84.00000000000065, 84.20000000000066, 84.40000000000066, 84.60000000000066, 84.80000000000067, 85.00000000000067, 85.20000000000067, 85.40000000000067, 85.60000000000068, 85.80000000000068, 86.00000000000068, 86.20000000000068, 86.40000000000069, 86.60000000000069, 86.8000000000007, 87.0000000000007, 87.2000000000007, 87.4000000000007, 87.6000000000007, 87.80000000000071, 88.00000000000071, 88.20000000000071, 88.40000000000072, 88.60000000000072, 88.80000000000072, 89.00000000000072, 89.20000000000073, 89.40000000000073, 89.60000000000073, 89.80000000000074, 90.00000000000074, 90.20000000000074, 90.40000000000074, 90.60000000000075, 90.80000000000075, 91.00000000000075, 91.20000000000076, 91.40000000000076, 91.60000000000076, 91.80000000000076, 92.00000000000077, 92.20000000000077, 92.40000000000077, 92.60000000000078, 92.80000000000078, 93.00000000000078, 93.20000000000078, 93.40000000000079, 93.60000000000079, 93.8000000000008, 94.0000000000008, 94.2000000000008, 94.4000000000008, 94.6000000000008, 94.80000000000081, 95.00000000000081, 95.20000000000081, 95.40000000000082, 95.60000000000082, 95.80000000000082, 96.00000000000082, 96.20000000000083, 96.40000000000083, 96.60000000000083, 96.80000000000084, 97.00000000000084, 97.20000000000084, 97.40000000000084, 97.60000000000085, 97.80000000000085, 98.00000000000085, 98.20000000000086, 98.40000000000086, 98.60000000000086, 98.80000000000086, 99.00000000000087, 99.20000000000087, 99.40000000000087, 99.60000000000088, 99.80000000000088]

You are seeing rounding errors. Read all about the phenomenon here: https://docs.python.org/3.9/tutorial/floatingpoint.html
Or see: https://floating-point-gui.de/

The question of rounding comes when there are numerous calculations. It is a simple multiple of 0.2 value without any rounding. Had it been extra zeros that would have been fine but it is giving wrong values. The links provided are giving explanation but not resolving the errors. Errors are Errors. These are errors and must be resolved.

The series must print 0, 0.2, 0.4, 0.6, … 99.8, 100 but here 0.6 became 0.6000000000000001, 1.6 became 1.5999999999999999, 1.8 became 1.7999999999999998, and the errors continues…

These are small calculations, for large calculations in finance these errors will make life of coders tedious and bring bad name to Python. No other programming language gives such errors. Moreover, previous versions were working fine. Why now the new change?

Check out the Decimal module if you’re doing financial calculations.

Please read the floating point guide more closely (emphasis added):

Why don’t my numbers, like 0.1 + 0.2 add up to a nice round 0.3, and instead I get a weird result like 0.30000000000000004?

Because internally, computers use a format (binary floating-point) that cannot accurately represent a number like 0.1, 0.2 or 0.3 at all.