我的Python学习之路(day1)
#Author:Tannarproduct_list = [
('Iphone',5800),
('Mac Pro',12888),
('iWatch',10600),
('Bike',7777),
('Python',77),
('Tea',27)
]
shopping_list = []
price = 0
salary = input("\033[41;1mInput your salary:\033[0m")
if salary.isdigit():
salary = int(salary)
while True:
for index, item in enumerate(product_list):
print(index, item)
user_choice = input("\033[43;1m选择要购买的商品>>>:\033[0m")
if user_choice.isdigit():
user_choice = int(user_choice)
if user_choice < len(product_list) and user_choice >= 0:
p_item = product_list
if p_item <= salary:
shopping_list.append(p_item)
salary -= p_item
price += p_item
print("\033,salary))
else:
print("\033[44;1m你的余额不足\033[0m")
else:
print("\033[44;1mProduct code is not exist\033[0m")
elif user_choice == 'q':
print("\033[44;1m--------------shopping list-----------------\033[0m")
for p in shopping_list:
print(p)
print("The totally price is ",price)
print("Your current balance is ",salary)
exit()
else:
print("\033[41;1mInvalid input\033[0m")
else:
print("\033[41;1mInvalid input\033[0m")
页:
[1]