This task would be a little simpler if we had a list of all the letter keys used in lst, but it's easy enough to extract them.
My strategy is to convert the sublists into dictionaries. That makes it easy & efficient to grab the value associated with each key. And the dict.get method allows us to supply a default value for missing keys.
lst = [[['a', 100],['b', 200],['d', 325]],[['a', 50],['b', 250],['c', 75]]]
# Convert outer sublists to dictionaries
dicts = [*map(dict, lst)]
# Get all the keys
keys = set()
for d in dicts:
keys.update(d.keys())
# Get data for each key from each dict, using 0 if a key is missing
final = [[k] + [d.get(k, 0) for d in dicts] for k in sorted(keys)]
print(final)
output
[['a', 100, 50], ['b', 200, 250], ['c', 0, 75], ['d', 325, 0]]
If we use
lst = [[['a', 100],['b', 200],['d', 325]],[['a', 50],['b', 250],['c', 75]], [['a', 22], ['b', 10]]]
then the output is
[['a', 100, 50, 22], ['b', 200, 250, 10], ['c', 0, 75, 0], ['d', 325, 0, 0]]
If you want to run this on Python 2 you need to make a minor change to the code that converts the outer sublists to dictionaries. Change it to
dicts = list(map(dict, lst))
That will work correctly on both Python 2 & 3. And if you only need to run it on Python 2, you could simply do
dicts = map(dict, lst)
since map in Python 2 return a list, not an iterator.
['c',0,75]?lstalways have that structure? IOW, will it always be a list of (lists of (two item lists))?c"key", so the OP want it to default to 0