Write a dynamic program to print out the dictionary containing alphabets as keys and their occurances as values from given input.
Write a dynamic program to print out the dictionary containing alphabets as keys and their occurances as values from given input.
sample input:
[email protected]
sample output:
{'s': 3, 'a': 3, 'r': 1, 'm': 2, 'p': 1, 't': 1, 'i': 1, 'l': 1}
sample input:
[email protected]
sample output:
{'i': 5, 'l': 1, 'a': 1, 'c': 2, 's': 3, 'e': 4, 'p': 1, 'r': 2, 'd': 1, 'n': 3, 'y': 2, 'u': 1, 'v': 1, 't': 1}
ANS:
word = input()
answer_dict = {}
for i in word:
if i.isalpha():
answer_dict[i] = word.count(i)
print(answer_dict)