Sum of list without lowest and highest list integers (python)
<p>Trying to practice my list comprehension, but at this point my code is looking a little (too) long per line length comprehension: </p>

<pre><code>def sum_array(arr):
    return 0 if arr == None else sum(sorted(arr)[1:-1] for x in range(len(arr or [])-2)) 
</code></pre>

<p>Objective is to calculate sum of integers minus the min and max. If array is empty, <code>None</code>, or if only 1 element exists, the function should return 0.</p>

<p>I am receivingthe following</p>

<blockquote>
  <p>TypeError: unsupported operand type(s) for +: 'int' and 'list'</p>
</blockquote>

<p>Please advise!  </p>

<p>Just an alternative way using <code>lambda</code> and <code>reduce</code>:</p>

<pre><code>s = 0 if arr == None else reduce(lambda x, y: x+y, sorted(arr)[1:-1])
</code></pre>

python if-statement list-comprehension