Lists+functions


#1

With this program I am getting o/p as none but it should be 2.Can anybody help me to find whats wrong with it.

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

fizz_count([“fizz”,“cat”,“fizz”])


#2

return is the result of for loop so it should be in the same line of for loop.


#3

Thanks ashish it worked


#4

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