def string_count(y): count = 0 for a in y: if(a=="ram"): count=count+1 print count else: print "zero" x = ["sizz" ,"vixx", "dfd" ,"ram","furram","ram"] string_count(x)