Пытался упростить про помощи for но не получилось.
Программа должна выдавать:
Лампа — 27 штук, стоимость 1134 рубля
Стол — 54 штуки, стоимость 27 860 рублей
Диван — 3 штуки, стоимость 3550 рублей
Стул — 105 штук, стоимость 10 311 рублей
goods = {
"Лампа" : "12345",
"Стол" : "12346",
"Диван" : "12347",
"Стул" : "12348"
}
store = {
"12345" : [
{"quantity" : 27, "price" : 42}
],
"12346" : [
{"quantity" : 22, "price" : 510},
{"quantity" : 32, "price" : 520}
],
"12347" : [
{"quantity" : 2, "price" : 1200},
{"quantity" : 1, "price" : 1150}
],
"12348" : [
{"quantity" : 50, "price" : 100},
{"quantity" : 12, "price" : 95},
{"quantity" : 43, "price" : 97}
],
}
goodss = store[goods["Лампа"]]
storecod = goodss[0]
quantity = storecod["quantity"]
goodss = store[goods["Лампа"]]
storecod = goodss[0]
prise = storecod["price"]
price = quantity * prise
print(f"Лампа - {quantity} штук, стоимость {price} рублей")
goodss = store[goods["Стол"]]
storecod = goodss[0]
storecod1 = goodss[1]
quantity1 = storecod["quantity"]
quantity2 = storecod1["quantity"]
quantity = storecod["quantity"] + storecod1["quantity"]
goodss = store[goods["Стол"]]
storecod = goodss[0]
storecod1 = goodss[1]
price1 = storecod["price"]
price2 = storecod1["price"]
price = quantity1 * price1 + quantity2 * price2
print(f"Стол - {quantity} штук, стоимость {price} рублей")
goodss = store[goods["Диван"]]
storecod = goodss[0]
storecod1 = goodss[1]
quantity1 = storecod["quantity"]
quantity2 = storecod1["quantity"]
quantity = storecod["quantity"] + storecod1["quantity"]
goodss = store[goods["Диван"]]
storecod = goodss[0]
storecod1 = goodss[1]
price1 = storecod["price"]
price2 = storecod1["price"]
price = quantity1 * price1 + quantity2 * price2
print(f"Диван - {quantity} штук, стоимость {price} рублей")
goodss = store[goods["Стул"]]
storecod = goodss[0]
storecod1 = goodss[1]
storecod2 = goodss[2]
quantity1 = storecod["quantity"]
quantity2 = storecod1["quantity"]
quantity3 = storecod2["quantity"]
quantity = storecod["quantity"] + storecod1["quantity"] + storecod2["quantity"]
goodss = store[goods["Стул"]]
storecod = goodss[0]
storecod1 = goodss[1]
storecod2 = goodss[2]
price1 = storecod["price"]
price2 = storecod1["price"]
price3 = storecod2["price"]
price = quantity1 * price1 + quantity2 * price2 + quantity3 * price3
print(f"Стул - {quantity} штук, стоимость {price} рублей")