# A Day at the Supermarket ( Exercise 4)

#1

Hi,
I keep getting the wrong answer--0--instead of 1. Could you all please tell me if what I am doing wrong. Thanks very much.

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

**Figured it out. Should have item as the variable in my if statement.

#2

You have some whitespace and syntax errors. Correct code:

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

fizz_count("fizz", "fizz", "buzz")``````

#3

here is my code:
def fizz_count(x):
count = 0
for item in x:
if item == "fizz":
count = count + 1
return count
fizz_count("fizz", "cazz", "minch", "fizz", "fizz"

why I get the message "return is outside funcion"?

#4

Your whitespace is wrong. Correct code:

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

fizz_count("fizz", "cazz", "minch", "fizz", "fizz")``````

#5

thank you! It works!!!

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

fizz_count("fizz", "fizz", "buzz")``````

Traceback (most recent call last):
File "python", line 9, in
TypeError: fizz_count() takes exactly 1 argument (3 given)

What makes it so it only takes 1 argument?

#7

There is only one argument because the only argument is the x that you defined at the very beginning. You have to enter it as a list to make it one argument.

Hope this helps.