+ 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)

16th Sep 2018, 7:28 PM
Anfernee Skinner
Anfernee Skinner - avatar
2 Respuestas
+ 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)
16th Sep 2018, 7:45 PM
davy hermans
davy hermans - avatar
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.
16th Sep 2018, 8:57 PM
benjamin