Help! lists + functions


#1




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


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


#2

Just use += instead of +. You should use it when you want to just add a number to a variable.


#3

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


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.