标签:continue coding 购物 cart input 工资 imp [] lis
#!/usr/bin/evn python
# -*- coding:utf-8 -*-
# Author: Aron
import sys
commodity = ‘‘‘
1.苹果 200
2.橘子 350
3.香蕉 500
4.水蜜桃 750
5.罗明 2000
‘‘‘
ShoppingCart = []
wages = int(input("你的工资:"))
while True:
print(commodity)
s1 = input("想购买的商品序号:")
if s1 == ‘1‘:
ShoppingCart.append([‘苹果‘,‘200‘])
continue
elif s1 == ‘2‘:
ShoppingCart.append([‘橘子‘,‘350‘])
continue
elif s1 == ‘3‘:
ShoppingCart.append([‘香蕉‘,‘500‘])
continue
elif s1 == ‘4‘:
ShoppingCart.append([‘水蜜桃‘,‘750‘])
continue
elif s1 == ‘5‘:
ShoppingCart.append([‘罗明‘,‘2000‘])
continue
elif s1 == ‘Q‘:
commodity1 = []
for i in list(ShoppingCart):
for i1 in list(i[::2]):
commodity1.append(i1)
for n in list(ShoppingCart):
for n1 in list(n[1:2]):
n1 = int(n1)
wages = wages - n1
for n in list(ShoppingCart):
for n1 in list(n[1:2]):
n1 = int(n1)
wages = wages - n1
if wages < 0:
wages = input("你的余额已经不足,请重新选购。请重新输入工资:")
ShoppingCart = [ ]
continue
else:
print("你够买的商品为:",list(commodity1))
print("你的余额为:%s" % wages)
sys.exit()
else:
print("输入错误,请重新输入:")
continue
标签:continue coding 购物 cart input 工资 imp [] lis
原文地址:http://www.cnblogs.com/huangbipeng/p/7606721.html