当前位置:   article > 正文

Python 练习之餐厅点菜_有位顾客来餐厅吃饭询问顾客是否点菜将顾客菜单存入列表中python

有位顾客来餐厅吃饭询问顾客是否点菜将顾客菜单存入列表中python

源代码如下:

##2019-05-31
##python
available_menus = ('french fries','chicken wings','hamburger',
	'egg tart','chicken nuggets')
order_dishes = []
order = input("please place the order: ")
if order == 'no,thanks':
	print("you are welcome!")
else:
	while order != 'done':
		order_dishes.append(str(order))					#这里的str()不可缺少
		order= input("any one else do you want: ")
	for order in order_dishes:
		if order in available_menus:
			if order == 'egg tart':
				print("sorry,we are out of egg tart right now.")
			else:
				print("Adding "+order+'.')
		else:
			print("Sorry,we don't have "+order+".")
	print("\nplesase check out your order!")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

运行结果如下:

D:\>python restaurant.py
please place the order: no,thanks
you are welcome!

D:\>python resta
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/80668
推荐阅读
相关标签
  

闽ICP备14008679号