ユーザーが小文字に入力するものを変更するコードがありますが、これを["a"または "A"]を使用する代わりに自分のコードにどのように実装すればよいでしょうか?ユーザー入力を小文字に変更するコード
optionchoice = input("Please enter A,B,C or D:").lower()
あなたはどんなユーザタイプの小文字バージョンへの入力を強制され、この方法:
def displaymenu():
print("Weather station")
print("Please enter the option you would like")
optionchoice = input("Please enter A,B,C or D:")
if optionchoice in ["a" or "A"]:
print("The temperature will be displayed")
time.sleep(1)
optionA()
elif optionchoice in ["b" or "B"]:
print("The wind speed will be displayed")
time.sleep(1)
optionB()
elif optionchoice in ["c" or "C"]:
print("The day and time will be displayed")
time.sleep(1)
optionC()
elif optionchoice in ["d" or "D"]:
print("The Location will be displayed")
time.sleep(1)
optionD()
else:
print("Please type a valid input")
displaymenu()
あなたをそれを小文字にするために '.lower()'を使うことができます – GreenSaber
私はこれを私のコードに入れてもらえませんか、全く分かりません –
'optionchoice = input(" A、B、CまたはDを入力してください。 () ' –