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


#1



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


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


#2

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


#3

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