title: How to structure the output in timedelta computation?
body: <p>I have 2 lists of dicts: </p>
  
  <pre><code>hah = [{1:[datetime(2014, 6, 26, 13, 7, 27), datetime(2014, 7, 26, 13, 7,27)]},
                    {2:datetime(2014, 5, 26,13,7,27)}]
  dateofstart = [{1:datetime(2013, 6, 26, 13, 7, 27)}, {2:datetime(2013, 6, 
                    26,13,7,27)}]` (just examples).
  </code></pre>
  
  <p>And I need to create a new list of <strong>dicts</strong> that contains the same keys and as a value has a difference between dates from the <strong>hah</strong> and <strong>dateofstart</strong>.</p>
  
  <p>It should look like this: </p>
  
  <pre><code>[{1:[365, 334]}, {2:[390]}]
  </code></pre>
  
  <p>When i tried to do it myself i got this code</p>
  
  <pre><code>dif = list()
  diff = list()
  for start in dateofstart:
      for time in hah:
          if start.keys() == time.keys():
              starttime = start.values()
              timeofpay = time.values()
              for payments in timeofpay:
                  dif.append(starttime.pop(0) - payments)
              diff.append({str(start.keys()):str(dif)})
  </code></pre>
  
  <p>And it runs with a following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/mihailbasmanov/Documents/date.py", line 78, in &lt;module&gt;
      dif.append(starttime.pop(0) - payments)
  TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'list'
  </code></pre>
  
  <p>Edition:</p>
  
  <p>Managed to do it (almost) by myself. Here is resulted code:</p>
  
  <pre><code>for start in dateofstartbuyer:
      for time in hah:
          if start.keys() == time.keys():
              starttime = start.values()
              starttimetime = starttime.pop(0)
              timeofpay = time.values()
              for payments in timeofpay:
                  if type(payments) == list:
                      for wtf in payments:
                          dif.append(wtf - starttimetime)
                  else:
                      dif.append(payments - starttimetime)
              key = str(start.keys())
              diff.append({key[1:2]:str(dif)})
              dif = list()
  print(diff)
  </code></pre>
  
  <p>If you have a suggestion how to make this code more productive your welcome to post your suggestions in the comments or in answers.</p>