Hi Counter
Finding a short substring is a basic skill for working with text, logs, and messages. Write a function count_hi that takes a string s and counts how many times the substring hi appears in it. Return that count as an integer.
Примеры
Ввод
"abc hi ho"Вывод
1Ввод
"ABChi hi"Вывод
2Ввод
"hihi"Вывод
2Нужно реализовать
def count_hi(s: str) -> int:
Теги
strings
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
"abc hi ho"Expected
12
Input
"ABChi hi"Expected
23
Input
"hihi"Expected
24
Input
"hellohi"Expected
15
Input
"xxhixx"Expected
16
Input
""Expected
0Focus radio
Paused · SomaFM · Fluid