У меня есть вложенный словарь
customer_order = {order0
{'Orientation': what_orientation, 'Size': what_size, 'sizecost': size_cost,
'eyelets': how_many_eyelets, 'eyeletcost': eyelet_cost, 'material': what_material,
'materialcost': material_cost, 'ropes': need_ropes, 'ropecost': rope_cost,
'image': need_image, 'imagecost': 0, 'wording': what_wording, 'wordcost':word_cost}
order1{'Orientation': what_orientation, 'Size': what_size, 'sizecost': size_cost,
'eyelets': how_many_eyelets, 'eyeletcost': eyelet_cost, 'material': what_material,
'materialcost': material_cost, 'ropes': need_ropes, 'ropecost': rope_cost,
'image': need_image, 'imagecost': 0, 'wording': what_wording, 'wordcost':word_cost}}
, что мне нужно сделать, это получить значение следующих ключей
sizecost
eyeletcost
materialcost
ropecost
wordcost
как мне пройти по циклу, чтобы получить эти значения и добавитьих к итоговой сумме?
Спасибо
Я попробовал приведенный ниже код, но получил ошибку
for key, value in cust_details:
ValueError: слишком много значений для распаковки (ожидается 2)
для cust_order, cust_details в customer_order.items (): print ("\ nOrder:", cust_order) для ключа, значение в cust_details: if (key == "sizecost"): totalcosts + = value
if (key == "eyeletcost"):
totalcosts += value
if (key == "materialcost"):
totalcosts += value
if (key == "ropecost"):
totalcosts += value
if (key == "wordcost"):
totalcosts += value
общая стоимость + = значение