from codebat:
Return True if the string "cat" and "dog" appear the same number of times in the given string.
cat_dog('catdog') → True
cat_dog('catcat') → False
cat_dog('1cat1cadodog') → True
here is my code:
Return True if the string "cat" and "dog" appear the same number of times in the given string.
cat_dog('catdog') → True
cat_dog('catcat') → False
cat_dog('1cat1cadodog') → True
here is my code:
def cat_dog(str): for i in range(len(str)-2): count_dog =0 count_cat=0 if str[i:i+3] == "cat": count_cat+=1 elif str[i:i+3] =="dog": count_dog+=1 if count_dog ==count_cat: return True else: return Falsewhere is the err?