#4 lists and functions


#1



Hello, my code keeps returning "0" for the count instead of the correct number "1". Could someone please explain where my code is incorrect.
Thank you


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


#2

here:

count == count + 1

this line, will check if count equals count + 1, why? i would update/re-assign count variable here.

Also, to print what the function returns, add the print statement before the function call


#3

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