I have 2 lists with tuples as their elements. One element of tuple is to be matched to the tuple from other list and corresponfing values are to be added from one tuple to another.
My 2 lists are :
l1 = [('Receipt total', 10),('Total Amount (AED)', 10),('Grand total', 10),('Net Amount', 9),
('Total Amount', 9),('Total (words are in between)', 6)]
l2 = [('Total Amount', ['593.52']), ('Total (words are in between)', ['593.52'])]
The keys Total Amount
and Total (words are in between)
in l2 are to be matched from l1 and the value corresponding to keys present in l1 9
and 6
respectively in this case are to be added to either l2 or a new list.
Expected output:
l2 = [('Total Amount', ['593.52'],[9]), ('Total (words are in between)', ['593.52'],[6])]
I'll be happy to provide further clarification and I am unable to think about this would happen and I am sorry if this seems too messy and I looked for similar questions but nothing seemed apt
Thank you!
question from:
https://stackoverflow.com/questions/65914028/find-common-values-from-2-list-of-tuples-and-add-the-values-from-one-tuple-to-an 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…