- くだすれPython(超初心者用) その32©2ch.net
841 :デフォルトの名無しさん[sage]:2017/03/17(金) 19:41:57.57 ID:dpI1G6OF - >>837
俺ならこうかな foods = ['和食', '洋食', '中華'] def choiceInput(prompt, choices): while True: print(prompt) choice = input('>') if choice in choices: return choice print('入力エラー') def order(): while True: print('和食, 洋食, 中華') choice = choiceInput('どれを食べますか (0/1/2)', ['0','1','2']) yesNo = choiceInput(f'{foods[choice]}で本当にいいですか(Y/N)', ['Y', 'y', 'N','n']) if yesNo in ['Y', 'y']: return choice
|