How do I add numbers in a list that do not equal parameters?
<p>I am trying to write a function that will add all of the numbers in a list that do not equal the parameters.  The code I have, that is not working, is:</p>

<pre><code>def suminout(nums,a,b):
    total=0
    for i in range(len(nums)):
        if nums[i]!=a or nums[i]!=b:
            total=total+nums[i]
    return total
</code></pre>

<p>It appears to be summing everything in the list.</p>

<p>For example, if I called:
suminout([1,2,3,4],1,2)
it should return 7.  However, I am getting 10.</p>

<p>Any thoughts?</p>

<p>As Kasramvd so duly noted, you need conjunction not disjunction.</p>

<p>Here is a list comprehension doing the same thing.</p>

<pre><code>def suminout(nums, a, b):
    total = 0
    total = sum([x for x in nums if (x!=a and x!=b)])
    return total
</code></pre>

python list parameters sum