python - unsupported operand type(s) for /: 'str' and 'str' -
this question has answer here:
print("please enter weight") weight = input(">") print("please enter height") height = input(">") bmi = weight/height if int(bmi) <= 18: print("you under weight") elif int(bmi)>=24: print("you normal weight") else: print("you on weight") traceback
file "c:\users\reazonsraj\desktop\123.py", line 6, in <module> bmi = weight/height typeerror: unsupported operand type(s) /: 'str' , 'str'
def enter_params(name): print("please enter {}".format(name)) try: return int(input(">")) except valueerror: raise typeerror("enter valid {}".format(name)) height = enter_params('height') weight = enter_params('weight') bmi = int(weight/height) if bmi <= 18: print("you under weight") elif bmi >= 24: print("you normal weight") else: print("you on weight")
Comments
Post a Comment