Replace this line with your code. def fizz_count(lost): count=0 for i in lost: if i=='fizz': count=+1 return count l=['fizz','fizz','cat','dog'] small=fizz_count(l)
i ma not able to print exact how many times fizz appears.
what is your question? what is the error you get?
i want to print how many times the string fizz is repeated in the the list.
its showing the count value should be 4
you store the result of the counting in small variable, so print small on the last line
its printing 1.every time.
did you add
print small as last line of code? it should print 2, given fizz is twice in your list
oops, i missed that.
we can update a variable like this:
a = 5 a = a + 5
we can also use a shorthand:
a = 5 a += 5
you use the shorthand, but incorrectly. you have
=+, while it should be
thanks bro.i got it.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.