0

I want someone to input their weight in lbs which is then converted to kg. However the output is just the converted number. I can't figure out how to label the output with "kg". ex: 72 kg

weight_lbs = input('Weight (lbs): ')

weight_kg = int(weight_lbs) * 0.45

kg = 'kg'

print(weight_kg + kg)

3 Answers 3

2

you need to do str(weight_kg) to make it a string type (instead of a number)

weight_lbs = input('Weight (lbs): ')

weight_kg = int(weight_lbs) * 0.45

kg = 'kg'

print(str(weight_kg) + kg)
Sign up to request clarification or add additional context in comments.

Comments

0

You can also just use %s and get rid of 'kg' = kg

print("%s %s" % (weight_kg,"kg"))

Comments

0

Another version of the twice upvoted answer:

weight_lbs = input('Weight (lbs): ')

weight_kg = str(int(weight_lbs) * 0.45)

kg = 'kg'

print(weight_kg + kg)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.