Search code examples
pythonsyntax-error

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

Solution

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