Lists + functions


can't really see why this code isn't working. when i run it, it shows 'Oops, try again. fizz_count(['fizz', 'buzz']) returned 0 instead of the correct answer: 1'

any help would be appreciated as i've been stuck on this excersise for a while now.

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


count == count + 1

== is a conditional operator.
It does not save something inside left of the variable but its used to compare and return booleans.

To do so we have operator called assignment operator = .
It save or sticks value to left of the variable.
for ex..

x = 4

and here we are saving the frequency of fizz to count variable.


thanks for that, it works now. and thanks for explaining why this is the case.


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