coder boy
coder boy

Reputation: 17

wrong output for python program in visual studio 2015

print("How many kms do you want to convert?");

kms = input();

miles = float(kms) / 1.60934;

print("OK converted data is :" + round(miles, 2));

I want to execute this python program in visual studio 2015 but when I enter a integer it returns nothing and when I enter a float number it returns this error: This is the output

Can you please correct my code?

Upvotes: 0

Views: 53

Answers (1)

Marvin Kim
Marvin Kim

Reputation: 26

I think the problem was the type of the round(miles, 2)

print("How many kms do you want to convert?")

kms = input()

miles = float(kms) / 1.60934

print("OK converted data is :" + str(round(miles, 2)))

this works for me, and about the semicolons, I don't know well about it(So do whatever you want)

And the problem was, that integer types and string types couldn't join via "+", so I added str() to convert it to string!

Upvotes: 1

Related Questions