python打印购物清单_python day1 (afternoon)购物清单

购物清单

#顾客给出余额

#给出商品清单

#顾客挑选商品

#给出购物清单

代码:

#!/usr/bin/env python

#-*- coding:utf-8 -*-

salary = int(input('plaese input your salary:'))

product_list = [[1, ['bike', 1500]], [2, ['IPhone', 8000]], [3, ['Mac Pro', 15000]], [4, ['fruit', 100]]]

shopping_list = []

while True:

for i in product_list:

print(i)

p = int(input('plaese pick commodity(product ID):'))

if salary >= product_list[p-1][1][1]:

salary = salary - product_list[p-1][1][1]

shopping_list.append(product_list[p-1][1])

k = input('do you want to shop something:')

if k[:1] in 'y':

continue

else:

break

else:

print('your balance is not enough')

break

count = 0

for x in shopping_list:

print(x)

count += x[1]

print('''

sum of consumption:{}

balance:{}

''' .format(count, salary))

pycharm python3.7可用


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部