title: Using lambda function in generator expression
body: <p>I am trying to count the total number of occurrences of a given val in the list using a <code>lambda</code> function:</p>
  <pre><code>def countOccurrence(givenList, val):
      result = sum(1 for i in range(len(givenList)) if lambda i: givenList(i) == val)
      return result
  
  givenList = [3, 4, 5, 8, 0, 3, 8, 5, 0, 3, 1, 5, 2, 3, 4, 2]
  print(countOccurrence(givenList, 5))
  </code></pre>
  <p>But the returned result is <code>16</code>, which is nothing but the length of the list.</p>