Formul error in Calculation

total_weighted_score = 0
total_supplier_score = 0

for item in doc.details:
    item.weighted_score = item.weight * item.supplier_score
    
    total_weighted_score = total_weighted_score + item.weighted_score
    total_supplier_score = total_supplier_score + item.supplier_score
    
    doc.total_weighted_score = total_weighted_score
    doc.total_supplier_score = total_supplier_score   

My code is not working well . Could anyone help me sort this

Hi @nik1 try this

total_weighted_score = 0
total_supplier_score = 0

for item in doc.details:
    item.weighted_score = item.weight * item.supplier_score
    
    total_weighted_score = total_weighted_score + item.weighted_score
    total_supplier_score = total_supplier_score + item.supplier_score
    
doc.total_weighted_score = total_weighted_score
doc.total_supplier_score = total_supplier_score