Help


#1

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

```python

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

fizz_count([“fizz”,“buzz”])

<do not remove the three backticks above>

#2

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’])


#3

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


#4

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