title: calculating average numbers from a dictionary of lists, python
body: <p>I my code I have a dictionary which has two lists combined with zip() function</p>
  
  <pre><code>self.dict = OrderedDict(zip(self.name,self.unit))
  </code></pre>
  
  <p>The lists are given as arguments... <code>var=class([[1,2,4,7],["y","y","t"],[11.1,12.3,6]],name=["num1","letter","num2"])</code></p>
  
  <p>In one point there should be a function which checks if the items in the each brackets has numbers only. for example <code>int=[1,2,3]</code>
  if that's true the program calculates the average for each number only list. And prints out the values as  <code>num1 = 3.5 num2 = 9.8</code> (as a table):</p>
  
  <pre><code>num1   num2
   3.5    9.8
  </code></pre>
  
  <p>First I make a new list using this:</p>
  
  <pre><code>for i in range(len(self.unit)):
                      if  all(isinstance(item, (int,float)) for item in self.unit[i]):
                          self.new_l.append(self.unit[i])
  </code></pre>
  
  <p>After that I (in another function) create a new list called <code>self.sum_l</code> in which put in the average of each number list in a new list of lists (In this example i get two averages).</p>
  
  <pre><code>self.sum_l.append([sum(self.new_1[i])/float(len(self.new_1[i]))])
  </code></pre>
  
  <p>After that I make a new dictionary which uses the <code>self.name</code> and the <code>self.sum_1</code> lists                        </p>
  
  <pre><code> self.nov_slovar = OrderedDict(zip(self.ime, self.seznam_vsot))
  </code></pre>
  
  <p>Which works fine, but the PROBLEM I'm facing is... when I create a new dictionary the code takes as much elements out of list <code>name</code> when forming a new dictionary, as there are lists in the <code>self.sum_1</code> list. But the thing is, it takes the first two (in my case). And that makes the output absolutely incorrect:</p>
  
  <pre><code>num1   letter
   4.6    9.8
  </code></pre>
  
  <p>So my question is, what should I do to prevent that from happening. I've tried many things. Even trying to calculate the sum of values in a dictionary, but I'm getting errors </p>