Python Shipping Lesson: weird number calculation?

I’m just getting started on this lesson, but I can’t get past this weird issue (bug?) with my variable calculations:

When I run my code, the resulting number is almost the correct amount but with a long decimal string at the end.

Example: I set the weight at 8.7 and calculated shipping cost as weight x 12. The simple math should be 104.4, but the resulting code shows “104.39999999999999”

I don’t understand why the math is slightly off.

1 Like

Sorry I jumped into asking before finishing this task, but the “Hint” also shows a long number string. I just don’t understand why this is the case when it’s a simple multiplication?

I guess I’ll finish the lesson before asking more questions here. The answer may be in there!

I understand floating point numbers, but I’m not doing any complicated math in this example. A simple math problem like 8.4 x 12 shouldn’t result in a long string of floating point numbers, right?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.