I’m currently working my way through the ‘Thread Shed’ exercise project in the Python 3 course.
I have a question about steps 13-15.
Here’s my code:
#10 customers =  sales =  thread_sold =  #13 total_sales = 0 #14 for sale in sales: s = float(sale.strip('$')) total_sales += s #15 print(format(total_sales, '.2f'))
given that the values in the list [sales] are all money values (ex: 12.23), how can the result be “1498.7400000000005”? I had to format it to 1498.74 in order for it to make sense as a money value. From my understanding, all the code is doing is sequentially adding values that were provided in the list.
How can the sum of a series of numbers that only extend to two digits right of the period return a number that is 13 digits right of the period? Did I do something wrong? The exercise says to use float. I can provide the list of numbers, but its quite long so it was intentionally excluded.