#4 Lists and Functions


#1



My code:

def fizz_count(x):
    count = 0
    for item in x:
        if item == "fizz":
            count + 1
    return count

result = fizz_count(["fizz","cat", "fizz"])
print result

This keeps returning

"Oops, try again. fizz_count(['fizz', 'buzz']) returned 0 instead of the correct answer: 1"

I have no idea what's wrong... have looked through the forums and can't figure it out.
Thanks for your help!


#2

the problem is in this line:

count + 1

this doesn't update your variable. To update your variable, re-assign it:

count = count + 1

this will update count (the current number in count + 1

You can shorten this line, but i will leave that to you


#3

Oh gosh that is incredibly obvious!!
Thank you for the help!