Exercise 17 

Write a program in Python to display for a given string the number of occurrences of each character in the string.
Example for the string s = "Python.org" the program must display:
The character: "P" appears once in the string s
The character: "y" appears once in the string s
The character: "t" figure 1 time in the string s
The character: "h" appears once in the string s
The character: "o" appears twice in the string s
The character: "n" appears once in the string s
The character: " . "figure 1 time in the string s
The character:" r "figure 1 time in the string s
The character:" g "figure 1 time in the string s

Solution

s = "Python programming"
for x in s:
print("The number of appearance of the
caraceter ", x, " in the chain s is :", s.count(x))
Younes Derfoufi
One thought on “Solution Exercise 17”

Leave a Reply