码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-12-28 21:49:09      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:python学习   log   i+1   练习   ubi   ipad   pytho   blog   off   

 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学习第二周-简易购物车练习

标签:python学习   log   i+1   练习   ubi   ipad   pytho   blog   off   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!