4 List + Functions


Guys i not understand my mistake. Thanks you all.


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

def fizz_count(function):
    count = 0
    for item in x:
        if item == 'fizz':
            count = count + 1
    return count
x = ['fizz', 'cat', 'fizz']
piece = fizz_count(x)
print piece


Hi @glucidi ,

You have this function header, with a parameter named function ...

def fizz_count(function):

Instead, the name of the parameter should be the same as the name of the list that you use inside the function. In the for loop, you are iterating through a list named x, so the parameter should be named, x, as well. Try this as the function header ...

def fizz_count(x):


yeeep!! Thnak you!! now i understand


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.