I seem to be using this block of code alot in Python.
if Y is not None:
obj[X][0]=Y
How do I establish a mapping from X=>Y and then iterate through this entire mapping while calling that block of code on X and Y
I seem to be using this block of code alot in Python.
if Y is not None:
obj[X][0]=Y
How do I establish a mapping from X=>Y and then iterate through this entire mapping while calling that block of code on X and Y
If Y is None, you can do something like:
default_value = 0
obj[X][0] = Y if not None else default_value
mapping = {X1: Y1, X2: Y2, X3: Y3}
mapping[X4] = Y4
mapping[X5] = Y5
for X,Y in mapping.items():
if Y is not None:
obj[X][0] = Y