首页 > 编程语言 > 详细

Python学习第二周-简易购物车练习

时间:2017-12-28 20:51:46      阅读:234      评论:0      收藏:0      [点我收藏+]
 1 list = ((1,iPhone X,8300),(2,iPad Pro,4600),(3,IBM z10,50000),(4,Coffee,30))
 2 print(Welecome to 7-11 !\n)
 3 print(There are:)
 4 for i in list:print(i)
 5 balance = int(input(\nPlease input your balance: \n))
 6 car = []  #car[name][prix]
 7 i = 0
 8 while True:
 9     code = input(Please input the code or input exit for exit:)
10     if code == exit:break
11     elif balance >= list[int(code)-1][2]:
12         code = int(code)
13         balance -= list[code-1][2]
14         car.insert(i,[i+1,list[code-1][1],list[code-1][2]])
15         i += 1
16     elif balance < list[int(code)-1][2]:
17         print(SO... !\n)
18     else:print(‘BIUBIUBIU)
19 for i in car:print(i)
20 print(balance)

 

Python学习第二周-简易购物车练习

原文:https://www.cnblogs.com/shuiyy/p/8137313.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!