print("Please enter your Weight")
weight = input(">")
print("Please enter your height")
height = input(">")
bmi = weight/height
if int(bmi) <= 18:
print("you are currently under weight")
elif int(bmi)>=24:
print("you are normal weight")
else:
print("you are over weight")
回溯
^{pr2}$
当输入数据时,它被保存为一个字符串。你需要做的是把它转换成一个int
这将解决一个问题,但不能解决所有问题。如果您要输入一个十进制数,那么您将收到一个
^{pr2}$ValueError
,因为int()
处理整数。要解决此问题,您需要使用float()
而不是int相关问题 更多 >
编程相关推荐