I want to iterate over 2 list of dictionaries in a single loop
This is what i got
a = [{'Date' : '123', 'amt' : '234'},{'Date' : '222','amt' : '458'}]
b = [{'Date' : '123', 'item' : '1'},{'Date' : '123', 'item' : '2'},{'Date' : '222', 'item' :'3'},{'Date' : '222', 'item' : '4'}]
txta = 'this is text a {Date} {amt}'
txtb = 'this is B {Date} {item}'
aa = [txta.format(**t) for t in a]
bb = [txtb.format(**z) for z in b]
data = aa+bb
print(data)
Current Output
['this is text a 123 234', 'this is text a 222 458', 'this is B 123 1', 'this is B 123 2', 'this is B 222 3', 'this is B 222 4']
Required Output
['''this is text a 123 234 ,this is B 123 1, this is B 123 2'''],['''this is text a 222 458, this is B 222 3, this is B 222 4''']
here the dictionary b's items are sorted in dictionary a where the key 'Date' is same .
Sorry if this is already asked, i did not get any.