my购物车

2023-01-31 00:01:07 购物车
sum=0
a=input("请输入“水果”或“衣服”:")
if a=="手机":
    while True:
        shop = { '蓝葡萄',  '水蜜桃',  '草莓'}
        print(shop)
        a = input("输入Buy进入结算,继续购买请输入物品名称:")
        if a == "蓝葡萄":
            a = int(shop["蓝葡萄"])
            sum += a
        elif a == "水蜜桃":
            a = int(shop["水蜜桃"])
            sum += a
        elif a == "草莓":
            a = int(shop["草莓"])
            sum += a
        elif a == "Buy":
            print(sum)
        else:
            print("输入有误!!!,请重新输入:")
elif a=="衣服":
    while True:
        shop = {'短裤':59,  '上衣':32, '衬衫':66}
        print(shop)
        a = input("输入Buy进入结算,继续购买请输入物品名称:")
        if a == "短裤":
            a = int(shop["短裤"])
            sum += a
        elif a == "上衣":
            a = int(shop["上衣"])
            sum += a
        elif a == "衬衫":
            a = int(shop["衬衫"])
            sum += a
        elif a == "Buy":
            print(sum)
        else:
            print("输入有误!!!,请重新输入:")
else:
    print ("输入有误!!!,请重新输入:")



 





相关文章