【发布时间】:2017-04-23 14:40:40
【问题描述】:
我正在尝试为学校做这个练习,但是在计算 BMI 之后,代码不起作用,恰恰是它不执行 if 语句。此外,如果输入不正确,则现在检查 except 语句。请告知代码中要更正的内容。谢谢!
user_input_1 = input('What is your weight')
user_input_2 = input('What is your height')
b = 'BMI'
b = int(user_input_1)/(float(user_input_2)**2)
while True:
try:
user_input_1 == int and user_input_1 > 0
user_input_2 == float and user_input_2 > 0
print(b)
if b in range(1, 19):
print('You are skinny as a rail')
break
if b in range(19, 26):
print('You are fit as a butcher\'s dog')
break
if b >= 25:
print('You are as plum as a partridge')
break
break
except ZeroDivisionError:
input('Enter your height in meters as a float')
except user_input_1 != int:
input('Please enter your weight in kg')
【问题讨论】:
标签: python python-2.7 while-loop try-except