Lesson 4: Lists + Functions


#1

my code:

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

result = fizz_count(["fizz","cat","fizz"])
print result


#2

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


#3

Hi its a indent problme your code should be like that

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

result = fizz_count(["fizz","cat","fizz"])
print result

the return statment shouldn't be inside the if statement


#4

Thank you for the help!