Lists + function


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

it doesnt return the count, result 1

def fizz_count(x):
    for item in x:
        if item == "fizz":
            count += count   
    return count 
our_count = (["fizz", "cat", "fizz"])
our_fizz = fizz_count(our_count)
print our_count



count += count

count is zero, so 0 + 0 will still be zero, increase count by one when fizz is found


yes i did,

if item == "fizz":
count == count + 1
it still returns 0


== is for comparison to check if things are equal, it doesn't assign a new value (update) the count variable, for this we need a single equal sign


yes i understand now
thank you :slight_smile: