小编Sri*_*ini的帖子

Python:如何使用list作为用户输入的选择源?

任何人都可以检查此代码,让我知道什么是错的?

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)

python input multiple-choice

7
推荐指数
2
解决办法
3万
查看次数

异常处理 - 如何处理用户输入中的无效数据类型?

作为编程新手,我正在尝试输入名称,这是一个字符串输入。如果我输入字符串以外的任何内容,错误应显示为无效输入类型。如何做到这一点?

python

5
推荐指数
1
解决办法
1万
查看次数

Python 3.3:以下代码的第7行中的语法错误无效

这是代码:

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行获取无效语法:

python

1
推荐指数
1
解决办法
138
查看次数

标签 统计

python ×3

input ×1

multiple-choice ×1