Bmi calculator


#1

Hi there,
I am new to this and I am experiencing a =n issue when trying to make my bmi calculator work:

name = input("please enter your name: ")
height_m = input("please enter height: ")
weight_kg = input("please enter your weight: ")
bmi = float(weight_kg) / float(height_m ** 2)
print ("bmi: ")
print (bmi)
if bmi < 25:
print (name)
print ("is not overweight: ")
else:
print(name)
print (“is overweight”)
this is the error I am getting:
TypeError Traceback (most recent call last)
in ()
2 height_m = input("please enter height: ")
3 weight_kg = input("please enter your weight: ")
----> 4 bmi = float(weight_kg) / float(height_m ** 2)
5 print ("bmi: ")
6 print (bmi)

TypeError: unsupported operand type(s) for ** or pow(): ‘str’ and ‘int’

cant figure out how to fix this
thanks


#2

height_kg and height_m are of type string (assuming python3)

doing ** for string and integer isn’t supported ,like the error message says. Both values here should be of type integer (or float)