def multi(*args): if len(args) > 1: return {arg:multi(*args[1:]) for arg in args[0]} else: return args[0] multi(['a', 'b'], ['A', 'B'], ['1', '2'], {})
returns
{'a': {'A': {'1': {}, '2': {}}, 'B': {'1': {}, '2': {}}}, 'b': {'A': {'1': {}, '2': {}}, 'B': {'1': {}, '2': {}}}}
EDIT . In my solution, the last argument {} will be copied to each output sheet as a reference to the same dictionary. If this is a problem (replacing it with an immutable object like float, integer or string, is another thing), use the idea of copy.copy @matt.
source share