Cat Dog Balance
Sometimes you need to check whether two markers appear in text the same number of times. Write a function cat_dog that takes a string s and counts the occurrences of the substrings cat and dog. Return True if the counts are equal, otherwise return False.
Примеры
Ввод
"catdog"Вывод
TrueВвод
"catcat"Вывод
FalseВвод
"1cat1cadodog"Вывод
TrueНужно реализовать
def cat_dog(s: str) -> bool:
Теги
strings
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
"catdog"Expected
True2
Input
"catcat"Expected
False3
Input
"1cat1cadodog"Expected
True4
Input
"catxxdogxxdog"Expected
False5
Input
"dogdogcat"Expected
False6
Input
""Expected
TrueFocus radio
Paused · SomaFM · Fluid