def multidict(*args):
    if len(args) == 1:
        return copy(args[0])
out = {}
for x in args[0]:
    out[x] = multidict(*args[1:])
return out
print(multidict(['a', 'b'], ['A', 'B'], ['1', '2'], {}))
Is there any elegant way to build a multi-level dictionary in python?