first month of learning Python so go easy.
I’m having a problem with my code, my program is for converting a measurement from meters into inches, feet and miles. The answer in miles comes out with about 9 decimal points so I want to show just the first 5. But I receive the error ‘invalid decimal literal’.
I used a similar formatting for another program for the radius of a circle here:
Pi = 3.14
r = float(input('What is the Radius of the Circle? '))
a = Pi * r * r
print(f" area = {a:.3f}")
Which worked fine. But here:
measurement = float(input("What is Your Measurement?: "))
#First to inches / 1m = 39.37in
print(float(39.37)*measurement)
#Then to feet / 1m = 3.28084f
print(float(3.28084)*measurement)
#Then to miles / 1m = 0.00062137mi
print(float(0.00062137)*measurement:.4f)
No luck. Any thoughts?
Gresh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.