Answer:
In Python:
chars = 'abcdefghijklmnopqrstuvwxyz'
letter = input("Sentence: ")
for i in range(len(chars)):
count = 0
for j in range(len(letter)):
if chars[i] == letter[j].lower():
count = count + 1
if count > 0 :
print(chars[i]+": "+str(count)+" times")
Explanation:
This initializes the characters of alphabet from a-z
chars = 'abcdefghijklmnopqrstuvwxyz'
This prompts the user for sentence
letter = input("Sentence: ")
This iterates through the initialized characters
for i in range(len(chars)):
This initializes count to 0
count = 0
This iterates through the input sentence
for j in range(len(letter)):
This compares the characters of the sentence with alphabet a-z
if chars[i] == letter[j].lower():
If there is a match, count is incremented by 1
count = count + 1
If there is an occurrence of character,
if count > 0 :
The character and its count is printed
print(chars[i]+": "+str(count)+" times")