Problem at Fizz count


I have entered the following code but it keeps returning fizz_count as 1 and I get an error message.

Write your function below!

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

bubbles = ["fizz", "cat", "fizz"]
print fizz_count(bubbles)

Can anyone tell me what I'm doing wrong and why it doesn't return 2?

Replace this line with your code.


We can't tell for sure but check if the return is inside the loop, or outside of it.


Thanks. The return code was indeed inside the loop. Thank you as return was with the "if" statement and not the "for" statement


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