title: <lambda>() takes 1 pos
body: <p>I am practicing using the functools.reduce() function with a lambda function. The problem I am having is that I keep getting an error. Here is my code: </p>
  
  <pre><code>&gt;&gt;&gt; from functools import reduce
  &gt;&gt;&gt; import math
  &gt;&gt;&gt; l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  &gt;&gt;&gt; reduce( (lambda x: math.sqrt(x)), l )
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>TypeError: &lt;lambda&gt;() takes 1 positional argument but 2 were given
  </code></pre>
  
  <p>I have moved parentheses around but nothing seems to work. For some reason, this code works just fine:</p>
  
  <pre><code>&gt;&gt;&gt; from functools import reduce
  &gt;&gt;&gt; reduce( (lambda x, y: x * y), [1, 2, 3, 4] )
  24
  &gt;&gt;&gt; reduce( (lambda x, y: x / y), [1, 2, 3, 4] )
  0.041666666666666664
  </code></pre>
  
  <p>but I can't see any difference other than that the second example has a second parameter y. Can anybody offer any advice on why I am getting this error?</p>