This is probably a fairly simple one, but I haven\'t figured it out quite right.
I have two lists of tuples
List_A
[(\'a\', 0.033), (\'b\', 0.030),
Put keys from List_B in a set and then use a simple for loop:
A = [('a', 0.033), ('b', 0.030), ('c', 0.020), ('d', 0.010), ('e', 0.005)]
B = [('a', 0.057), ('b', 0.065), ('w', 0.060), ('x', 0.040), ('y', 0.010)]
B_keys = {k for k, _ in B}
for k, _ in A:
if k not in B_keys:
B.append((k, 0.0))
B
#[('a', 0.057),
# ('b', 0.065),
# ('w', 0.06),
# ('x', 0.04),
# ('y', 0.01),
# ('c', 0.0),
# ('d', 0.0),
# ('e', 0.0)]