title: How can I debug this error? object of type 'generator' has no len()
body: <p>I'm trying to compute the mean values of the numbers in a list of lists, I'm supposed to skip over the first observation (i.e position 0) because they are the names of countries, I only need to calculate the mean of every column after <code>[0]</code>. However, my code keeps saying:</p>
  
  <p><code>TypeError: object of type 'generator' has no len()</code></p>
  
  <p>If anyone could have a look and offer some help, I would greatly appreciate it. Thank you!</p>
  
  <p>I've tried this code: </p>
  
  <pre><code>def my_mean1(file):    
      mean_list = []
      for column in range(1,len(file[0])):
          column_values = (row[column] for row in file)
  
          # calculate the mean but not with the statistics module
          mean_values = sum(column_values) / len(column_values)
          mean_list.append(mean_values(x for x in column_values if x is not None))    
      return mean_list
  </code></pre>
  
  <p>The results I expect</p>
  
  <pre><code>test = [['str1', 2.66171813, 7.460143566, 0.490880072, 52.33952713, 0.427010864, -0.106340349, 0.261178523], ['str2', 4.639548302, 9.373718262, 0.637698293, 69.05165863, 0.74961102, -0.035140377, 0.457737535]]
  </code></pre>
  
  <pre><code>test1 = data(file) # a function that made the list of lists
  </code></pre>
  
  <pre><code>my_mean(test)
  [5.022380471333333, 9.327360550833333, 0.7483190200000001, 65.42301750166666, 0.6615842928333333, -0.05882061216666667, 0.3449308604]
  </code></pre>
  
  <p>but the error I encounter when I use <code>test</code></p>
  
  <pre><code>TypeError: object of type 'generator' has no len()
  </code></pre>
  
  <p>and the error I encounter when I try <code>test1</code></p>
  
  <pre><code>TypeError: unsupported operand type(s) for +: 'int' and 'str'
  </code></pre>