# Lists + Functions 4/13 python help

def fizz_count(x):# Write your function below!
count = 0
for item in x:
if x = fizz:
count = count + 1
return count
return fizz

@cloudrunner04788 take a look at the excerpt below

``````def fizz_count(x):# Write your function below!
count = 0
#loop through x for each element
#we are calling it item
for item in x:
#here we want to check if item(the current element)
# matches "fizz" and not fizz(without quotes)
#remember that in python this "=" is the assignment
#operator we use it when we are creating variables
#but this "==" is the equality(a comparison) operator
# which is used when we want to check
#if two things are equal
if item == "fizz":
count = count + 1

#Here you want to just return count
# once you callreturn in a method the method will
#terminate and anything wriiten in the method
#after that will not be executed
return count

print fizz_count(["fizz", 'fizz'])

``````
4 Likes

This is for future references.
my code was like this(is in spanish i hope is not problem)
def contar_burbujas(x):
(this is the mistake)
x = [âburbujasâ, ârandom wordâ, âburbujasâ, ârandom wordâ](end of the mistake)
contar = 0
for palabra in x:
if palabra == âburbujasâ:
contar = contar + 1
return contar
the mistake was that i was declaring the items in the list

def fizz_count(x):# Write your function below!
count = 0
for item in x:
if item == âfizzâ:
count = count + 1
return count

print fizz_count([âfizzâ, âfizzâ])

This is what worked.
Just copy the exact code and paste it will work and make sure the indentation is right.
Do not edit the code.
Most people get an error message as Error: fizz_count([âfizzâ, âbuzzâ]) returned 0 instead of the correct answer: 1 or whatsoever.

def fizz_count(x):

count = 0

for item in x:

``````if item == "fizz":

count = count + 1
``````

return count

print fizz_count([âfizzâ,âcatâ,âfizzâ])