+ 1
Why won't my output display?
def conversion(km): miles = km*0.6214 return miles km=float(input("Enter the distance in kilometers: ")) distance_in_miles=conversion(km) print("The distance in miles is: ", distance_in_miles)
2 Respostas
+ 3
The indentation is wrong. Change it to this.
def conversion(km):
miles = km*0.6214
return miles
km=float(input("Enter the distance in kilometers: "))
distance_in_miles=conversion(km)
print("The distance in miles is: ", distance_in_miles)
0
Also, once you've sorted your indentation, you could concatenate the return value straight into the string.
https://code.sololearn.com/cF1U9JOMKQJy/?ref=app
Although I would advise against typecasting in one line when taking user input. If they input a value that cannot be cast, an error will be thrown. Better to typecast in a separate try statement.