运行此代码时出现此错误
line 101, in seventh_question
if int(weight) >= heightandweight[height][2]:
KeyError: 187
代码:
def seventh_question():
height = int(input("\nWhat is your height in centimeters? "))
if height < 147:
height = 147
if height >= 193:
height = 193
weight = int(input("\nWhat is your weight in Kg's? "))
if int(weight) >= heightandweight[height][2]:
return 3
if int(weight) >= heightandweight[height][1]:
return 2
if int(weight) >= heightandweight[height][0]:
return 1
with open("height_weight.json") as f:
heightandweight = json.load(f)
f.close()