1. 程式人生 > >python筆記:購物車

python筆記:購物車

python 購物車


product_list=[
    (,),
    (,),
    (,),
    (,),
    (,),
    (,),
]
shopping_list = []salary = ()salary.isdigit():salary =(salary)
    :
        index,item (product_list):(index,item)
        user_choice = ()
        user_choice.isdigit():user_choice =(user_choice)user_choice< (product_list) user_choice >=:p_item =product_list[user_choice]p_item[]<= salary:shopping_list.append(p_item)salary -= p_item[](%(p_item,salary))
                :
                    (%salary)
            :
                  (% user_choice)
        user_choice ==:()
            p shopping_list:
                (p)
            (,salary)
            ()
    :
        ()


python筆記:購物車