Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I`m stuck in this code. Always getting an error when I`m trying to execute this code. (I`m beginner in python)

Current Code:

weight_lbs=float(input("How much do you weigh(lbs)? : " ))
weight_kg=float(input("My weight is " + weight_lbs/2.205 + "kg"))
print(weight_kg)

Error Message:

Traceback (most recent call last):
File "<string>", line 9, in <module>
TypeError: can only concatenate str (not "float") to str

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

weight_lbs = float(input("How much do you weigh(lbs)? : " ))

kg = str(weight_lbs/2.205)

print("My weight is " + kg + "kg")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading