标签:arm color ice email 简单 soft har compute dig
1 # -*- coding: utf-8 -*- 2 # @Time : 2018-05-31 14:56 3 # @Author : 超人 4 # @Email : huxiaojiu111@gmail.com 5 # @File : 购物车小练习 6 # @Software: PyCharm 7 8 9 goods_list = [ 10 [‘apple‘,30], 11 [‘car‘,80000], 12 [‘tesla‘,999999], 13 [‘computer‘,20000] 14 ] 15 shopping_car=[] 16 money = input(‘请输入购买金额:‘) 17 if money.isdigit(): 18 money=int(money) 19 while True: 20 for i,o in enumerate(goods_list): 21 print(i,o) 22 goods_id = input(‘请输入购买的商品序号[退出q]:‘) 23 if goods_id.isdigit(): 24 goods_id=int(goods_id) 25 if goods_id>=0 and goods_id<len(goods_list): 26 goods_price=goods_list[goods_id] 27 money=money-goods_price[1] 28 if money>0: 29 print(goods_price) 30 shopping_car.append(goods_price) 31 else: 32 print(‘余额不足‘) 33 break 34 else: 35 print(‘商品编号不存在‘) 36 elif goods_id == ‘q‘: 37 print(‘-----------------------购买如下商品-------------------------------‘) 38 for i in shopping_car: 39 print(i) 40 print(‘剩余%s元钱‘%money) 41 break 42 else: 43 print(‘请输入合法字符!‘)
标签:arm color ice email 简单 soft har compute dig
原文地址:https://www.cnblogs.com/chaoren-hu/p/9117632.html