LIST + FUNCTION fizz_count([4, 'fizz', 7, 'fizz', 'fizz', 10, 'fizz']) returned 1 instead of the correct answer: 4


def fizz_count(x):
count = 0
for fizz in x:
if fizz == "fizz":
count += 1
return count
print fizz_count(["fizz","cat","fizz"])


Hi @panushalimbu ,

Because the code that you posted is not formatted, it is difficult for other users to read and debug it. After code has been pasted into the editing window for posting, you can format it by selecting it, and then by clicking the </> button above the editing area. Alternatively, you can place three backquotes on the line before the code and three backquotes on the line after the code. This will enable us to see important details, such as the indentation and underscores. If you use the backquotes, your code will be color-coded, making it especially easy to read.

Make sure this statement is indented by only one level ...

return count

If it is indented by two levels, it is part of the loop, and will return during the first iteration of the loop.