Count Example


I wrote down this piece of code and it didnt work. I see that you wrote the same code. Do you know why it doenst work?

It gives this error:

Oops, try again. Does your count function take exactly two arguments: a list and an item to check against that list? Your code threw a "list indices must be integers, not str" error.

def count(sequence,item):
    c = 0
    for i in sequence:
        if sequence[i] == item:
        c += 1 
    return c


you c += 1 needs to be indented, try to use just if i == item