我需要帮助我的if / else语句用于哪个奇迹字符问卷如何添加"而#34;使python编码正确。谢谢。我想确保他们不能输入除A,B,C或OR之外的任何字母。
if str(input())) not ('A','B','C','D')
else ("ask them again");
答案 0 :(得分:1)
一个简单的选项是检查每个字母:
choice='f'
while choice!='A' and choice!='B' and choice!='C' and choice!='D':
choice=input('Enter letter')
如果您想在.upper()
input(..)
进行检查
答案 1 :(得分:1)
answer = ""
possibleAnswers = {"A","B","C","D"}
while answer not in possibleAnswers:
answer = input("Select an answer:")