shopping cart

Posted lanfriend

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shopping cart相关的知识,希望对你有一定的参考价值。

product_list = [
(‘phone1‘,5000),
(‘phone2‘,4000),
(‘phone3‘,3000),
(‘phone4‘,2000),
(‘phone5‘,1000),
(‘phone6‘,100),
]
shopping_list = []
salary = input("your salary:")
if salary.isdigit():
salary = int(salary)
while True:
for index,item in enumerate(product_list):
print(index,item)
user_choice = input("要什么:")
if user_choice.isdigit():
user_choice = int(user_choice)
if user_choice < len(product_list) and user_choice >= 0:
p_item = product_list[user_choice]
if p_item[1] <= salary:
shopping_list.append(p_item)
salary -= p_item[1]
print("Added %s to shopping cart,your current balance is %s"%(p_item,salary))
else:
print("only [%s],not enough "%salary)
else:
print("product code [%s] is not exist!"%user_choice)
elif user_choice == ‘q‘:
print("-------shopping_list-------")
for p in shopping_list:
print(p)
print("Your current balance is ",salary)
exit()
else:
print("Invalid option")



































以上是关于shopping cart的主要内容,如果未能解决你的问题,请参考以下文章

flow-shop调度问题job shop调度问题open shop调度问题 是什么 区别

shop--6.店铺注册

如何使用 CsvHelper 解决 CSV 映射问题

数据分析

关系“mains_shop”不存在第 1 行:SELECT COUNT(*) AS “__count” FROM “mains_shop”

什么是go-shop period