Lists + function


#1


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):
    count=0
    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

#2

here:

count += count

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


#3

yes i did,

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


#4

== 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


#5

yes i understand now
thank you :slight_smile:


#6