# 用户输入工资
balance = int(input(
"Please input balance:"
))
# 定义衣服的数组
clothes = [[
"pants"
,100],[
"T-shirt"
,50],[
"skirt"
,20]]
# 个人所得,包括金钱和获取的物品
haveGoods = [balance,[]]
flag = True
while
flag:
# 打印衣服列表
print
(
"The clothes list is as follows"
)
print
(
"______clothesList______"
)
i = 1;
for
c in clothes:
print
(
'The number:'
,i,
":"
,c)
i += 1
# 用户输入商品编号
code = int(input(
"Please choose the number:"
))
# 判断钱是否够用
if
clothes[code-1][1] <= haveGoods[0]:
# 在自己的购物清单中加入已购物品
haveGoods[1].append(clothes[code-1])
# 减去花费的金钱
haveGoods[0] -= clothes[code-1][1]
print
(
"You have successfully purchased!"
)
print
(
"Your account balance is:"
,haveGoods[0])
else
:
print
(
"Your account balance is insufficient!"
)
print
(
"Your account balance is:"
,haveGoods[0])
judge = input(
"You can press any button to continue,or input 'n' to leave:"
)
if
judge ==
"n"
:
flag = False
print
(
"Your account balance is:"
,haveGoods[0])
print
(
"Your shopping list is as follows:"
)
print
(
"______clothesList______"
)
for
h in haveGoods[1]:
print
(h)