Conversion code

Hi all,
I’m trying to figure out this code to print the conversion of miles to km and vice versa.

kilometers = 12.25
miles = 7.38

miles_to_kilometers = 1.61
kilometers_to_miles = 0.62

print(miles, "miles is", round(miles_to_kilometers, 2), "kilometers")
print(kilometers, "kilometers is", round(kilometers_to_miles, 2), "miles")

What am I missing? I want to print out the conversion but I don’t/can’t see the operation I’m missing.
Thanks for any help

Although the lines output by the program claim to be a conversion, that’s not happening (at least not yet). It’s just printing the factor between miles and km. You’d need to multiply by that factor to get the converted distance.

miles * miles_to_kilometers would generate the number of kilometers.

1 Like

Many thx. After walking away for a few minutes, I discovered what I was doing wrong. Sometimes it’s good to take a walk to clear your head!