# 4/10 Lists and Functions Help Please!

#1

def fizz_count(fizz):
total = 0
for x in fizz:
if x = fizz
total = total + 1
x = ["fizz","cat","fizz"]
count = fizz_count(x)
return count
print fizz

While I know the indentations are a little messed up, besides that, I am not sure where to go from here, or even if I got any of this code correct. Any help would be greatly appreciated. Thank you!

#3
``````def fizz_count(fizz):
total = 0
for x in fizz:
if x == "fizz":
total = total + 1
x = ["fizz","cat","fizz"]
count = fizz_count(x)
print count``````

This function will count the number of times the text 'fizz' appears in an array. Your answer is correct up until the conditional test, 'if x = fizz' three problems with this, the equality test to use is ==, to test the text fizz, it needs to be in quotes to make it a string, otherwise it looks for a variable, and you need a colon : at the end to identity what comes after as its code block. After that with the right indents it's okay, but you don't want to use 'return' outside of a function, you can 'print count' to output the answer, and print fizz is attempting to print an undefined variable, as fizz doesn't exist outside of the function.

#5

Not sure why I couldn't edit that, the post lost its indentation and I tried to fix it. Here's another angle to look at the problem with the count function embedded in the fizz_count.

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

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

#6

thank you so much!!!