标签:exce int cond serial type iphone tin item ==
购物车
1 list = ["Headset","Book ","Mp3 ","Camare","Condom","Alienware","Iphone7"] 2 price = [800,60,300,5000,34,20000,6000] 3 basket = [] 4 salary ="1" 5 while type(salary) != type(1): 6 try: 7 salary = int(input("please input your salary:")) 8 except: 9 print("Please enter number !") 10 while True: 11 print("You can buy the following things:") 12 for i in range(1,len(list)+1): 13 print (i,". ",list[i-1],‘\t‘,price[i-1]) 14 while True: 15 choice = input("please enter the serial number of the item you want: ‘q‘ is exit!") 16 if choice == "q": 17 print("You bought something below:", ‘\n‘,basket, ‘\n‘, "your balance:", salary, ‘\n‘, "byebye!") 18 exit() 19 try: 20 choice = int(choice) 21 except: 22 print("Wrong type!") 23 continue 24 if choice < 1 or choice >7 : 25 print("Wrong number!") 26 continue 27 else: 28 price_choice = price[choice-1] 29 if price_choice > salary: 30 differ = price_choice - salary 31 print("Sorry,You‘re worse than", differ) 32 else : 33 salary = salary - price_choice 34 basket.append(list[choice-1]) 35 print("you got the",list[choice-1]) 36 print("your balance:",salary)
标签:exce int cond serial type iphone tin item ==
原文地址:http://www.cnblogs.com/kimyeee/p/6637622.html