python create nested directory based on two lists
<p>Good morning,</p>

<p>This might be easy but IÂ´m just starting with python. For learning:
Is there are 'cleaner' way creating a nested dict based on two lists than this:</p>

<pre><code>person = ['mama.a','mama.b', 'mama.c',
         'mama.d', 'papa.a', 'papa.b']
kind = ['a', 'b', 'c', 'd']
combined = {}

# GOAL:
# {'mama': {'a': [], 'c': [], 'b': [], 'd': []}, 'papa': {'a': [], 'c': [], 'b': [], 'd': []}}

for human in [i.split('.')[0] for i in person]:
    combined[human] = {}
    for attrib in kind:
        combined[human][attrib] = []
</code></pre>

<pre><code>combined = {x.split('.')[0]:{i:[] for i in kind} for x in person} #if you require no check as to whether mama or papa contain a, b, c, or d
print combined

neutral = {i.split('.')[0]:[n.split('.')[1] for n in person if n.split('.')[0] == i.split('.')[0]] for i in person} #if you require a check
combined = {k:{v:[] for v in neutral[k]} for k in neutral}
print combined
</code></pre>

python list