标签:输入 nbsp bsp [] end ping span break car
shopping = [[‘house‘,1000000],[‘book‘,50],[‘iphone‘,3000]] qian = input(‘请输入你的钱:‘) shoppingcar = [] if qian.isdigit(): qian = int(qian) while True: for i,v in enumerate(shopping,1): print(i,v) goumai = input(‘请输入你要购买的商品编号(退出请按q):‘) if goumai.isdigit(): goumai = int(goumai) if 0<goumai<=len(shopping): goumait = shopping[goumai-1] if goumait[1] < qian: qian -= goumait[1] print(‘恭喜你购买成功%s,余额为%d‘%(goumait,qian)) shoppingcar.append(goumait) else: print(‘你的余额不足‘) else: print(‘你输入的商品不存在,请重新输入‘) elif goumai == ‘q‘or goumai == ‘Q‘: print(‘您已经购买如下商品‘) for i in shoppingcar: print(i) print(‘你还剩下,%d‘%qian) break else: print(‘你输入的商品不存在‘) else: print(‘你输入RMB有误‘)
标签:输入 nbsp bsp [] end ping span break car
原文地址:http://www.cnblogs.com/lazily/p/7892356.html