3.购物车
来源:互联网 发布:webview 加载js 阻塞 编辑:程序博客网 时间:2024/06/15 18:58
product_list = [ ('iphone', 5800), ('Mac Pro', 9800), ('Bike', 800), ('Watch', 10600), ('Cofee', 31), ('python', 120)]shopping_list = []def panduan(string): s = str(string) if s.count('.') == 1: sl = s.split('.') left = sl[0] right = sl[1] if left.isdigit() & right.isdigit(): return True else: return False elif s.isdigit(): return True else: return Falsesalary = input("Input your salary:")if panduan(salary): salary = float(salary) while True: for index, item in enumerate(product_list): print(index, item) user_choose = input("请输入商品编号:") if user_choose.isdigit(): user_choose = int(user_choose) if user_choose < len(product_list) and user_choose > 0: s = product_list[user_choose] if s[1] <= salary: shopping_list.append(s) salary -= s[1] print('added %s into your shopping cart ,your balance is \033[31;1m%s\033[0m' % (s[0], salary)) else: print('your salary can not affrond') else: print('您输入的商品编号不存在...') elif user_choose == 'q': print('----------shopping list-------------') for i in shopping_list: print(i) print('余额:', salary) print('------------------------------------') exit() else: print('无效编号!!!')
阅读全文
2 0
- 3.购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- 购物车
- Android proc目录
- 数组名的意义
- 移动端fixed和input获取焦点软键盘弹出影响定位的问题
- hihoCoder #1497 : Queen Attack
- 原生js模拟锚点,实现点击后,内容定位到本页的对应位置
- 3.购物车
- 人人网2011前端工程师笔试卷
- HDOJ1257 最少拦截系统(DP,LIS模板,low_bound)
- 低功耗项目小小心得
- 文件上传下载之commons-fileupload
- 《深入理解Java虚拟机》第7章 虚拟机类加载机制
- linux 默认系统语言修改
- 定义不被SpringMVC拦截的静态资源(html, js, css等文件)通用方法
- SpringData Jpa 入门(基本配置)