我正在为学校编写的Bmi计算器向后产生我的输出,它首先调用用户信息,然后调用名称信息。请帮帮忙,我需要的是相反的方式。
user = str
end = False
def bmi_intro():
print("BMI Calculator")
while end == False:
user = input("Enter students name or '0' to quit: ")
if user == "0":
print("end of report!")
else:
def userName(str):
user = str
print("Lets gather your information,", user)
break
get_height = float(input("Please enter your height in inches: "))
get_weight = float(input("Please enter your weight: "))
body_mass_index = (get_weight * 703) / (get_height ** 2)
print ("Your bmi is: ", body_mass_index)
def main():
get_height = 0.0
get_weight = 0.0
body_mass_index = 0.0
bmi_intro()
发布于 2018-06-11 00:58:44
更正缩进和删除break
语句可以解决您的问题(我已经尝试尽可能少地编辑您的代码,我认为这将有助于您理解代码):
user = str
end = False
def bmi_intro():
print("BMI Calculator")
while end == False:
user = input("Enter students name or '0' to quit: ")
if user == "0":
print("end of report!")
break
else:
def userName(str):
user = str
print("Lets gather your information,", user)
get_height = float(input("Please enter your height in inches: "))
get_weight = float(input("Please enter your weight: "))
body_mass_index = (get_weight * 703) / (get_height ** 2)
print ("Your bmi is: ", body_mass_index)
def main():
get_height = 0.0
get_weight = 0.0
body_mass_index = 0.0
bmi_intro()
https://stackoverflow.com/questions/50785979
复制相似问题