所以我正在做一个你输入输入的项目,一旦你做了它就匹配立方体,金字塔,椭圆体,退出之一,或者它回到原来的问题
我希望用户能够以任何大写或小写的形式输入任何这些单词,所以一个例子就是我希望cUbe或cubE与立方体做同样的事情
while True:
shape = input("What shape would you like?: ")
if (shape == "cube" ) : #Calculating cube volume
cube_func()
continue
答案 0 :(得分:2)
你可以使用shape.lower()将字符串转换为小写字母。
while True:
shape = input("What shape would you like?: ")
if (shape.lower() == "cube" ) : #Calculating cube volume
cube_func()
continue