我創建了一個程序,給定佣金的百分比並給出發票,它將查找給定的發票,查找該發票的值並計算基於百分比輸入的佣金。當我們輸入"calculate"
時,它將總計所有佣金並給我佣金總額。Python,列表的搜索列表並給出下一個值
我在嘗試識別列表中的輸入時遇到了問題。一旦我這樣做了,我必須做些什麼來賦予發票的價值?
data base = [Invoice, Invoice amount, invoice margin]
這是我到目前爲止所。
data_base = [["f1",2000,.24],["f2",150000,.32],["f3",345000,.32]]
comission_percentage = int(input("Comision Percentage: "))
invoice = input("Enter an invoice: ")
total_comision = 0
while invoice != "calculate" :
while invoice in data_base:
invoice_ = data_base.index(invoice)+1 #Gives me the position of invoice
invoice_amount = data_base[p_factura] #Give me the value os the invoice
comission = ((margen_comisionar/100)* monto_factura) #calculatecomission
total_comision = comission + total_comission
invoice = input("Enter an invoice: ")
print("The amount to comission is: " + str(total_comission))
你面臨什麼問題?從列表中獲取數據? – Sarvesh
你應該試試這個代碼。檢查名稱和縮進 total = 0 invoice =「calculate」 while invoice!='calculate' for data_base: total = total + item [1] * comission_percentage/100 invoice = input(「Enter invoice:」) – Sarvesh