I'm able to achieve this but think there must be a better way of doing it. The idea is to have common solution for both the cases.
Problem:
a & b are two dictionaries . values of these dictionaries could be a simple string (use case 1) or lists of same length (use case 2). Please note that length of these lists could be different between a & b (ex:- Key '2' in use case 2) but length within the same dictionary is same.
Expected:
We need to create a final dictionary which will have keys from both the dictionaries a & b and consolidate those values (be it a string or list) as lists of lengths equivalent to longest from either of the dictionaries. For ex:- In use case 2, Key 2 has ["abc","def"] in dictionary a but just ["abc"] in dictionary b.Here we are expecting final result as 2: ["abc","def","abc",None].
Examples:
use case 1:
a = {1:"xyz",2:999,3:1234,4:"boy"}
b = {1:"xyz",2:99,3:19,6:"toy"}
Result expected : {1: ['xyz', 'xyz'], 2: [999, 99], 3: [1234, 19], 4: ['boy', None],
6: ['None', 'toy']
use case 2:
a = {1:["xyz","123"],2:["abc","def"],3:["zzz",""],4:["boy","abc"]}
b = {1:["xyz","1234"],2:["abc"],3:["zz",""], 6: ["toy"]}
result expected: {1: [('xyz', 'xyz'), ('123', '1234')], 2: [('abc', 'abc'), ('def', None)],
3: [('zzz', 'zz'), ('', '')], 4: [('boy', None), ('abc', None)],
6: [(None, 'toy')]})