Having Problems with my code


def fizz_count(x):
for item in x:
if “fizz” == item:
count= count + 1
return count
a_list = [“fizz”, “cat”, “fizz”]
print fizz_count(a_list)

That is my code and it output 1, when it should output two. The lesson(4/13) was asking me to create a program that counted the number of time fizz appears in the list. Please Help?


Check that the return is outside of the loop. It may have too much indentation.

for ...
    if ...
return ...


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