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


#1


Hi everyone. I would like help figuring this out.

Here is the think:

https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/0/4?curriculum_id=4f89dab3d788890003000096

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

#2

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.


#3

I tried it and it worked! Thanks a bunch!