4/10 Please help. I have no idea where I am going wrong


#1

So I looked at the other answers for 4/10 and I am still stuck.

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

x = ['fizz', 'fizz']
print fizz_count(x)

This is my code. I have no idea why its not working. I've tried count += 1. I've tried messing with x. I am not getting anything. I know there is a fundamental error in my code because the error messages don't make sense. I keep getting back an error message: fizz_count(['fIzZ', 5, 'fuzz', 'fizz', 'fizz']) returned 1 instead of the correct answer: 2.

Any help would be appreciated.

-A


#2

fixed it by following the example, indentations are very important, also the way I incremented the variable was important.
def fizz_count(x):
count = 0
for item in x:
if item == 'fizz':
count = count + 1
return count

thanks for allowing a space to ask, I have received a lot of assistance via the meesage boards


#3

Apparently this post has to be at least 20 characters. So I want to take the time and say: Thank you, Morgan!


#4

glad you got it solved, yeah, its hard to tell when you this format

code example:
    indentations is easier to see here

you use 4 spaces to format your code like that


#5

def contar_burbujas(x):
contar=0
for n in x:
if n == "burbujas":
contar = contar + 1
return contar

burbujas = ["burbujas","perro","burbujas"]
print contar_burbujas(burbujas)


#6

your code is not complete, because you finiched in return.


#7

It should be look like this:
x = (['clock', 'fizz', 'dog', 'cat', 'fizz'])

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


#8

Pay attention in spaces!