7-5 character occurrences statistics (20 points)

7-5 character occurrences statistics (20 points)

This problem requires writing programs, statistics and output frequency of a given character appears in a given string.

Input formats:

The first line of a given input string carriage return (less than 80 characters); a second input line of a character.

Output formats:

The output of a given number of characters that appear in a given string in a row.

Sample input:

programming is More fun!
m

Sample output:

2
s = input()
c = input()

ch = {}
for i in s:
    ch[i] = ch.get(i, 0) + 1

print(ch.get(c, 0))

Guess you like

Origin www.cnblogs.com/nobilis/p/11878460.html