4. List + Functions (I need help figuring this out)


Hi everyone. I would like help figuring this out.

Here is the think:


I keep getting error. It says it returned 0 instead of 2.

I've done what it asked. I tried other ways but I think I'm missing something.

# Write your function below!
def fizz_count(x):
    count = 0
    for item in x:
        if item == "fizz":
            count += 1
        return count
result = ["fizz", "cat", "fizz"]
another = fizz_count(result)
print another


You've got a problem with indentation in your function - return count is being called on the first iteration of the loop, rather than after the end of the loop.


I tried it and it worked! Thanks a bunch!