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

Tukaj bo rezultat izvajanja kode

Tests12
Visible tests
Skriti test 7
Skriti test 8
Skriti test 9
Skriti test 10
Skriti test 11
Skriti test 12

They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.

Focus radio
Paused · SomaFM · Fluid