一个购物车
1 # coding=utf-8 2 # Author: RyAn Bi 3 import sys , os 4 5 goods = [['iphone',5800],['mate20pro',5000],['mix3',3999],['oneplus',2999]] 6 mycho = [] 7 money = input('your salary is :') 8 money = int(money) 9 q = 0 10 while q == 0 : 11 print('1 iphone 5800 2 mate20pro 5800 3 mix3 5800 4 1plus 2999 whice one do you like?') 12 com_number = input('input the number,if you dot buy anything ,pls input q:') 13 com_number = int(com_number) 14 if q != 1: 15 tmp1 = goods[com_number] 16 mycho = mycho.append(tmp1) 17 print('you choice the %s'%(mycho)) 18 else : 19 for i in mycho: 20 money= money- mycho[i][1] 21 22 if money > 0: 23 print('you choice the %s'%(mycho)) 24 q = 1 25 else : 26 print('your money is not enough,whice one you want to drop?') 27 print('you choice the %s'%(mycho)) 28 com_number =input('your number or q?') 29 if com_number != q : 30 mycho = mycho.remove(com_number) 31 continue 32 else: 33 q =1 34 break