title: Problems while converting a tuple-dict to a valid dict?
body: <p>Given the code snippet below</p>
  <pre><code>tupled-dict:{
   ('apples', 'no'): 1,
   ('apples', 'yes'): 1,
   ('grapes', 'no'): 5,
   ('grapes', 'yes'): 6,
   ('cherry', 'no'): 2,
   ('cherry', 'yes'): 2,
   ('orange', 'yes'): 3,
   (&quot;mango's of india&quot;, 'no'): 1,
   (&quot;mango's of india&quot;, 'yes'): 1,
   ('chocolate', 'no'): 2,
   ('chocolate', 'yes'): 2,
   ('tomatoes', 'no'): 2,
   ('tomatoes', 'yes'): 3,
   ('pineapple', 'no'): 4,
   ('pineapple', 'yes'): 2,
   ('peas', 'no'): 3}
  </code></pre>
  <p>How can I create a shorter version like this:</p>
  <pre><code>{'apples': {'availability': {'yes': 1, 'no': 1}},
   'grapes': {'availability': {'yes': 6, 'no': 5}},
   'cherry': {'availability': {'yes': 2, 'no': 2}},
   'orange': {'availability': {'yes': 3, 'no': 0}},
   &quot;mango's of india&quot;: {'availability': {'yes': 1, 'no': 1}},
   'chocolate': {'availability': {'yes': 2, 'no': 2}},
   'tomatoes': {'availability': {'yes': 2, 'no': 3}},
   'pineapple': {'availability': {'yes': 4, 'no': 2}},
   'peas': {'availability': {'yes': 3, 'no': 0}}}
  </code></pre>
  <p>I tried to iterate throught the tuples, and extract the each fruit and availability to create and nest the dictionary like this:</p>
  <pre><code>l=[]
  helper_dict = {}
  
  for e in a_dict.keys():
      l.append(e)
      fruits = list(set([i[0] for i in l]))
  
  for e in fruits:
      try:
          helper_dict[e]['Yes']= a_dict[str(e),'Yes']
      except KeyError:
          helper_dict[e]['Yes']= 0
  </code></pre>
  <p>However, I am finding it complicated to create this structure when there is missing one availability. For example, <code>('peas', 'no'): 3</code> only has 3:no, as there is no <code>('peas', 'yes')</code>, I would assume and update the dictionary as <code>('peas', 'no'): 0</code>. Same for <code>orange</code>, because there is only <code>3:yes</code>, and <code>0:no</code>. Any idea of how to do this less complicated?</p>