Lists + Functions


While doing the lesson, i wrote this and got a correct answer. Now, i get that the function did its purpose, since it did not found any fizz, it returned zero. I cant seem to grasp where i should put the list that should be checked for string fizz ?

# Write your function below!
def fizz_count(x):
    count = 0
    for n in x:
        if n == "fizz":
            count = count + 1
    return count


Hello, @hexapod666!
Edit: Changed my answer, got what you mean.

The list is supposed to be passed outside and after the function has been created.
Simply do the following:

myList = ["fizz","cat","fizz"] #You could also pass only the list, there's not really a need to store it into a variable

Quote me if there's anything else I can help you with!

Best regards,


Hello @g4be

I cant get the correct output for my code

Write your function below!

def fizz_count(x):
    for item in x:
    return count
myList = ['fizz','buzz']
print z

The output is 0 and I get an error saying that it returned zero instead of the correct answer


That's your problem!
You're supposed to increase the value in the variable count because this way you're only adding zero with zero, over and over again.

Best regards,


R8!! Thanks.. Completely missed it :slightly_smiling:


No problem! Glad to help!