How to make a function that calculate elements in list?
<p>I'm doing my heart game programming but I'm confused on how to calculate all the scores in each card 
This is the card that has value, other cards have 0 value</p>

<pre><code>&gt;&gt;&gt; card_value ={"QS":13,"2H":1,"3H":1,"4H":1,"5H":1,"6H":1,"7H":1,"8H":1,"9H":1,"0H":1,"JH":1,"QH":1,"KH":1,"AH":1,"0D": -10}
</code></pre>

<p>but if all the sub lists in a set of lists contain a heart then the score will be -26 and if all the sub lists in a set of lists contain a heart and 10 Diamonds("0D") then the score will be -36 <br/></p>

<p><em>example</em></p>

<pre><code>&gt;&gt;&gt; list1 = [['QD', '7D', '5H', '0D'], ['7C', '6D', '2H', 'KS'], ['8S', '3D', '9C', 'KD'], ['4D', '9D', 'KH', '4C'],['7S', 'JH', '4H', 'QC'], ['2S', 'KC', 'AD', 'AC'], ['JD', '8D', 'QS', '6H'], ['AH', '9H', '9S', '6S'],['5S', '0S', 'JC', '2D'],['5D', '8H', '0C', '7H'], ['JS', '6C', '2C', 'AS'], ['3S', '4S', '5C', '0H'], ['3C', 'QH', '3H', '8C']]
</code></pre>

<p>The output from this will be -36</p>

<pre><code>&gt;&gt;&gt; list2 = ["5C","QS","JH"]
</code></pre>

<p>The output from this will be 14</p>

<p>this is what I have tried so far:</p>

<pre><code>def score(list,score=0):
    for cards in list:
        if cards in card_value.keys():
            score += card_value[cards]    
        if cards == "H":
            score = -36
        if cards == "H" or "0D":
            score = -26
   return score
</code></pre>
