这段代码存在语法错误,应该使用elif来表示多个条件分支,比如:

if BMI1 <= 18.5: print("偏瘦") elif BMI1 > 18.5 and BMI1 <= 25: print("正常") elif BMI1 > 25 and BMI1 <= 30: print("偏胖") else: print("肥胖")

注意,每个分支都应该以elif开头,最后一个分支使用else。否则会出现语法错误。

python查找问题:if BMI1<=18.5:
 print(18.5 and BMI1<=25: print("正常") else BMI1 > 25 and BMI1 <= 30: print("偏胖") else: print("肥胖")" title="python查找问题:if BMI1<=18.5: print("偏瘦") else BMI1>18.5 and BMI1<=25: print("正常") else BMI1 > 25 and BMI1 <= 30: print("偏胖") else: print("肥胖")" loading="lazy">

原文地址: https://www.cveoy.top/t/topic/zYj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录