4. Lists + Functions (What's wrong with my code?)



fizz_count(['fizz', 'fizz', 'fizz', 6, 'fIzZ', 'fizz']) returned 1 instead of the correct answer: 4

I expect the output to come out as the correct number of "fizz".

def fizz_count(x):
    count = 0
    for word in x:
        if word == "fizz":
            count = count + 1
            return count
number = fizz_count(["fizz","pop","guzzle","fizz","stream"])
print number


This line should be inside neither the if nor the for. Remove indent so the line is under the for.


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