4 List + Functions


#1



Guys i not understand my mistake. Thanks you all.


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


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


#2

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):

#3

yeeep!! Thnak you!! now i understand


#4

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