Simple Shopping cart Function: Enter the existing amount, choose shopping, determine whether the amount is sufficient, end printing the current purchases, the remaining amount, etc.
Goods_list = ((' Tesla ', 900000), (' Mate ', 4000), (' Apple X ', 7000), (' bens ', 1000000), (' movie ', ' Max '), (' Bicycle ', 1500))
Shopping_car = []
Print (' ========== Welcome to my shop ========== ')
For i,v in Enumerate (goods_list,1):
Print (I, '--', V)
Print (' ========================================== ')
saving = input (' Please input your saving: ')
If Saving.isdigit ():
saving = Int (saving)
While True:
Choice = input (' Plesse input your choice: ')
If Choice.isdigit ():
Choice = Int (choice)
If Choice>0 and Choice<=len (goods_list):
Choice_goods = goods_list[choice-1]
#print (Choice_goods)
If saving >= choice_goods[1]:
SAVING-=CHOICE_GOODS[1]
Shopping_car.append (Choice_goods)
Else
Print (' Please input correct number! ')
elif Choice = = ' Q ':
Print (' ============ your shopping car ============ ')
For I in Shopping_car:
Print (i)
Print (' You hava%s '%saving)
Break
Else
Print (' Please input correct number! ')
Else
Print (' Please input correct number! ')
5. A brief discussion of Python's simple shopping cart