what's wrong with my code? countconsonant
<pre><code>def countConsonant (s):

    """Count consonants.

    'y' and 'Y' are not consonants.

    Params: s (string)
    Returns: (int) #consonants in s (either case)
    """

    # do not use a brute force solution:
    # think of a short elegant solution (mine is 5 lines long);
    # do not use lines longer than 80 characters long

    # INSERT YOUR CODE HERE, replacing 'pass'
    countConsonant = 0
    for index in s:
        if index == 'bcdfghjklmnpqrstvwxyz':
            countConsonant += 1
    return countConsonant 

print (countConsonant ('"Carpe diem", every day.')) # should return 8
</code></pre>

<p>With the statement </p>

<p><code>for index in s:</code> </p>

<p>you are iterating over all the characters in s. So the condition </p>

<p><code>if index == 'bcdfghjklmnpqrstvwxyz':</code></p>

<p>ever evaluates to<code>False</code> and the function returns 0 in every cases.</p>

<p>To check the membership of a character in a string, you need to use the <code>in</code> operator rather than <code>==</code>, which checks for the equality of the values. </p>

<p>If your algorithm is case independent, you could either lowercase the input or add all the corresponding uppercase letters to the string <code>'bcdfghjklmnpqrstvwxz'</code>. Since <code>'y'</code> and <code>'Y'</code> are not consonants as per your requirement, you need to remove <code>y</code> from the string <code>'bcdfghjklmnpqrstvwxyz'</code>. And your final code is</p>

<pre><code>def countConsonant (s):

    """Count consonants.

    'y' and 'Y' are not consonants.

    Params: s (string)
    Returns: (int) #consonants in s (either case)
    """
    countConsonant = 0
    for index in s.lower():
        if index in 'bcdfghjklmnpqrstvwxz':
            countConsonant += 1
    return countConsonant 

print (countConsonant ('"Carpe diem", every day.')) # should return 8
</code></pre>

python