python 小程序—循环和列表训练


a=input('please input your salary:')
purchase=[]
while True:
products=[[1,'iphone',5800],[2,'book',50],[3,'bike',800],[4,'coffee',40]]
for i in products:
print i
b=raw_input('please input the thing what you want buy(put Q or q to end):')
if b.upper()=='Q':
break
elif products[int(b)-1][2]>a:
print 'your money is not enough,choose other'
else:
a=a-products[int(b)-1][2]
purchase.append(products[int(b)-1]) print 'the next is what you have bought:'
print 'your balance is %s'%a
for i in purchase:
print i

运行结果:

python 小程序—循环和列表训练

上一篇:2019.03.09 codeforces833B. The Bakery(线段树优化dp)


下一篇:Workbook导出excel封装的工具类