title: List of tuples and mean calculation
body: <p>I have the following list of tuples:</p>
  <pre><code>list = [(120, 'x'), (1120, 'y'), (1330, 'x'), (0, 't'), (1, 'x'), (0, 'd'), (2435, 'x')]
  </code></pre>
  <p>I would like to calculate the mean of the first component of all tuples. I did the following:</p>
  <pre><code>s = []
  for i in range(len(list)):
      a = list[0][i]
      if a =! 0:
          s.append(a)
      else:
          pass
  mean = sum(s) / len(s)
  </code></pre>
  <p>and it works, but my question is whether there is any way to avoid using for loops? since I have a  very large list of tuples and due to time calculation I need to find another way if that possible.</p>
  <p>According to the above stated  for loop method. How could I find the mean with regard to the wights? I mean, e.g. the last element in the list is <code>(2435, 'x')</code> and the number <code>2435</code> is very large in comparison to that one in <code>(1, 'x') </code> which is <code>1</code>. Any ideas would be very appreciated. Thanks in advance.</p>