Skip to content

Instantly share code, notes, and snippets.

Created March 17, 2017 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0e784ef30407afdba925627e4a459e75 to your computer and use it in GitHub Desktop.
Save anonymous/0e784ef30407afdba925627e4a459e75 to your computer and use it in GitHub Desktop.
注文を取る
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
foods = {'0': '和食', '1': '洋食', '2': '中華'}
def order():
while True:
print(list(foods.values()))
print('どれを食べますか (0/1/2)')
choice = input('>')
if choice not in foods:
print('入力エラー')
continue
break
while True:
print(f'{foods[choice]}で本当にいいですか(Y/N)')
answer = input('>')
if answer in ['n', 'N']:
return order()
elif answer not in ['y', 'Y']:
print('入力エラー')
continue
break
return choice
def main():
choice = order()
print(f'{foods[choice]}を注文します')
print('完了')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment