計算總價格不超預算以及商品的總價格

budget = int(input(「請輸入你的預算:」)) prices = input(「請輸入各個商品的價格:」).strip().split() l = [] for price in prices: l.append(int(price)) l.sort() sum = 0 #給個索引是爲後面sum > budget減去臨界值 index = 0 for i in range(len(
相關文章
相關標籤/搜索