List + Functions No idea what I am doing wrong


#1



I am stuck on the List + Functions exercise (4. List + Functions)


I am getting the following error message:
Oops, try again. fizz_count(['fuzz', 'fizz', 5, 'fizz', 'fuzz', 'fizz']) returned 0 instead of the correct answer: 3


I am not sure what is supposed to happen. Where do I include my list for the function to run?


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


#2

a function ends the moment a return keyword is reached

so your function ends in the first run of the loop, which can't be right

you can add a function call and pass in a list as argument


#3

I'm sorry, I still don't understand what you are saying. Can you provide a syntax example? Should it look something like this?

a = ['fizz', 'fizz', 'fizz']
x = fizz_count(a)
print small


#4

that will do, now x contains the returned value by the function, so you should print x, not small


#5

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