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
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
"catdog"
ExpectedTrue
2
Input
"catcat"
ExpectedFalse
3
Input
"1cat1cadodog"
ExpectedTrue
4
Input
"catxxdogxxdog"
ExpectedFalse
5
Input
"dogdogcat"
ExpectedFalse
6
Input
""
ExpectedTrue
Focus radio
Paused · SomaFM · Fluid