Please help! Lists + Functions - Stuck on fizz count :(


Hi there,

Stuck on one of the exercises in this module.

I'm getting this error message repeatedly but not sure where I went wrong?

Oops, try again. fizz_count(['fizz', 'fizz', 1, 'fuzz', 'fizz', 'buzz', 'fizz', 5, 10]) returned 1 instead of the correct answer: 4

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

thank you :sweat:


a function ends the moment a return keyword is reached, this currently happens in the first iteration of your loop, so return will break the loop at the end of the first iteration

Place return outside your loop so the whole loop can run


Aha! Got it :relieved:
Super thanks!