Character Count

Easy · rating 950 · strings

The first line is a string. The second line is a single character. Print how many times that character appears in the string.

Editorial

Character Count counts how many times a given character appears in a string — a single scan tallying matches, or a built-in count method.

print(s.count(ch))

Complexity

Time: O(n). Space: O(1).

Open Character Count in Code Arena →