Problem at Fizz count


#1



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


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.


#2

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


#3

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


#4

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