This always returns a 0 and I have no idea why pls help.


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


<do not remove the three backticks above>


That’s because the list that your ‘fizz_count(x)’ function is counting from only contains one ‘fizz’.

The final line of you code should look something like this:

fizz_count([‘fizz’, ‘buzz’, ‘fizz’])


The problem is the line:
if x==“fizz”:
x is the list, you need to compare the individual items in the list which you have from:
for item in x:
you just need to swap what you are comparing


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