4. List & Functions


#1

It keeps printing 0 instead of 1. Why?

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

x = ["fizz","buzz"]
small = fizz_count(x)
print small


#2

pretty sure i got all the indentations right


#3

error message: Oops, try again.
fizz_count(['fizz', 'buzz']) returned 0 instead of the correct answer: 1


#4

I've had this problem before too. The issue is that instead of:

for item in x:
    if x == "fizz"

it should be:

for item in x:
    if item == "fizz":

because each element in the list named "x" has been labelled 'item'. I hope this helps!