Help with 11.count


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/1


Oops, try again. Your function fails on count([4, 'foo', 5, 'foo'],5). It returns 0 when it should return 1.

found should be iterated by 1


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


#2

found will always return as 0. We need to preserve the sequence passed to the function, so that line can be safely removed.

There is a problem with the iteration. Since i is the iterator variable in a for statement, we do not need to increment it. That step can also be safely removed.

That just leaves the if statement. Consider the following:

for el in my_list:
    if el == item:
        found += 1
return found

Notice how we compare the element to the item?