Solution Exercise 17: number of occurrences of a character in a Python string

Exercise 17

Write a Python program to display for a given string of characters "s", the number of occurrences of each character in the string "s".
Example for the string s = "Python.org" the program should display:
The character: "P" appears once in the string s
The character: "y" appears once in the string s
The character: "t" appears once 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: ". " appears once in the string s
The character: "r" appears once in the string s
The character: "g" appears once in the string s


Solution




 

Younes Derfoufi
CRMEF OUJDA

1 thought on “Solution Exercise 17: number of occurrences of a character in a Python string

Leave a Reply