#!/usr/bin/env python# -*- coding: utf-8 -*-#如下是一个购物程序:#先输入工资,显示商品列表,购买,quit退出,最后格式化输出所买的商品。count = 0while True: #做一个循环判断,如果输入的不是数字,基于提示,三次后退出salary = input("input your salary:") #输入你的工资if salary.isdigit(): #输入的工资必须是数字才能往下走salary=int(salary) #转换为整数型breakelse:print("Please input a number:")count += 1if count == 3:exit()goods_list = [["Iphone",5800],["Macbook",12800],["iMac",15000],["ApplePen",500],["IPod",1200]] #商品列表shop_list = [] #购买的商品列表msg = " Product List "print(msg.center(30,"*"))for i,ele in enumerate(goods_list): #遍历序列中的元素以及它们的下标print(i,".",ele[0],ele[1])while True:choice = inpu
...
继续阅读
(26)