暗号化プログラムを作成する必要があり、割り当ての途中です。以下にリストされているのは、この部分の説明です。e、d、またはqが入力されていない場合、Pythonにwhileループをやり直すように指示するにはどうすればよいですか?私のqエントリは正常に機能しますが、ご覧のとおり、ユーザーが別の文字を入力した場合のケースを作成するための支援が必要です。
whileループを使用して、ユーザーが「e」、「d」、または「q」を入力していることを確認して、不正な入力をやり直します。次に、StartMenu()は選択内容をmain()関数に戻す必要があります。ここで、main()の変数がその戻り値をキャッチする必要があります。
def PrintDescription():
print 'This program encrypts and descrypts messages using multiple \
encryption methods.\nInput files must be in the same directory as this program.\
\nOutput files will be created in this same directory.'
def StartMenu():
print 'Do you wish to encrypt or decrypt?'
print '<e>ncrypt'
print '<d>ecrypt'
print '<q>uit'
def main():
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.?! \t\n\r"
PrintDescription()
while True:
StartMenu()
a = raw_input("")
if a!='e' and a!='d' and a!='q':
print 'You must enter e, d or q'
False
break
if a == 'q':
break