任何人都可以检查此代码,让我知道什么是错的?
input_list = ["One", "Two", "Three"]
P1 = input("Select the input: ", input_list[0], input_list[1], input_list[2])
print (P1)
Run Code Online (Sandbox Code Playgroud) 作为编程新手,我正在尝试输入名称,这是一个字符串输入。如果我输入字符串以外的任何内容,错误应显示为无效输入类型。如何做到这一点?
这是代码:
Weight = float(input("Enter weight in Kilograms: "))
Height = float(input("Enter height in meters: "))
BMI = (Weight / (Height**2))
print ("%.2f" %BMI)
if BMI < 18.5:
print ("You are under weight")
elif BMI >= 18.5 and < 25.0:
print ("You weight is normal")
elif BMI >= 25.0 and < 30.0:
print ("You are overweight")
elif BMI >= 30.0:
print ("You are overweight")
Run Code Online (Sandbox Code Playgroud)
在elif BMI> = 18.5和<25.0行获取无效语法: