menu_list =[ {"id": 1, "name":"1.糖醋排骨","price":34,"$":"元"}, {"id": 2, "name":
"2.糖醋鱼", "price": 23,"$":"元"}, {"id": 3, "name":"3.大盘鸡", "price": 65,"$":"元"}, {
"id": 4, "name":"4.红烧肉", "price": 66,"$":"元"}, {"id": 5, "name":"5.梅菜扣肉","price"
:21,"$":"元"}] Order_list = [] print(
'==========================欢迎光临王老狗饭馆,祝您用餐愉快===================================='
) print('今日菜单:') for menu in menu_list: print(menu.get('name'),menu.get('price')
,menu.get('$')) while True: print('='*50) print("1.用户点餐\n2.取消点餐\n3.确认菜单\n4.结账")
server= int(input("请选择服务:")) if server == 1: while True: menu_add = input(
"请输入菜名编号或输入Y结束点菜:") if menu_add.upper() != 'Y': for m in menu_list: if m.get(
'id')== int(menu_add): Order_list.append(m) break else: print(
'==================已点菜=====================') total_price = 0 for order in
Order_list: print(order.get('name'),order.get('price'),order.get('$'))
total_price+= int(order.get('price')) print(' 小计:{}元'.format(total_price)) break
elif server == 2: menu_del = input("请输入要取消的菜名:") for order in Order_list: if
order.get('id') == int(menu_del): Order_list.remove(order) print(
'==================已点菜=====================') total_price = 0 for order in
Order_list: print(order.get('name'),order.get('price'),order.get('$'))
total_price+= int(order.get('price')) print(' 小计:{}元'.format(total_price)) elif
server== 3: print('==================已点菜=====================') total_price = 0
for order in Order_list: print(order.get('name'),order.get('price'),order.get(
'$')) total_price += int(order.get('price')) print(' 小计:{}元'.format(total_price)
) elif server == 4: print('=================您的消费菜单=======================')
total_price= 0 for order in Order_list: print(order.get('name'),order.get(
'price'),order.get('$')) total_price += int(order.get('price')) print('
总计消费:{}元'.format(total_price)) print(
'==================欢迎您再次光临,再见!=====================') break

技术
友情链接
码工具
Toolsou
API参考文档
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信