4/13 im doing it right and its not working!


#1

Write your function below!

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

so here is my code and I'm getting "Oops, try again. fizz_count([1, 7, 'buzz', 'fizz', 'fuzz', 'fizz']) returned 0 instead of the correct answer: 2" as my error but whatever i do nothing works. Plz help

#2

Please edit your post to format the code sample. Type a blank line above the code and in that line, three back-ticks, and at the end of the code enter a blank line and repeat. Thank you.

```

Your code here

```


#3

It is not clear if you done well the spaces that structure the code in Python, so I put my code here (it worked for me), and I expect that maybe you can find something useful....

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

#4

Hi @davidloco4 ,

All of the code inside the function needs to be indented with respect to the function header, as follows ...

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

#5

Thaks. It worked but the 'return' needs some sort of indentation


#6

Where is everyone getting target from? I didn't use that and my code worked fine.

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

#7

its not working for me please help

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

error:
Oops, try again. fizz_count(['fizz', 'fizz', 7, 10]) returned 1 instead of the correct answer: 2