cucumbers isn’t a float, how did
total_cost end up being a float?
When we do math between an integer and a float, the result will always be a float. This is a good rule to keep in mind because it can cause unexpected and incorrect values if you try dividing two integer values that are not evenly divisible. The simple solution is what we’ve done in this exercise: convert one of the involved numbers to a float so that the result becomes a float.
Take a look at these examples:
my_float = 70. float_2 = 70.0 my_int = 70 float_result = 70 / 2.0 float_result_2 = 70. / 2.0 float_result_3 = 70.0 / 2 int_result = 70 / 7
Try running that code and printing the values. Were the results as you expected?