Letter Counter Program | Python Programming | Dictionary

preview_player
Показать описание
In this video we are solving an Question

Question :-

Given a string as input, you need to output how many times each letter appears in the string.
You decide to store the data in a dictionary, with the letters as the keys, and the corresponding counts as the values.
Create a program to take a string as input and output a dictionary, which represents the letter count.

Sample Input:
hello

Sample Output:
{'h': 1, 'e': 1, 'l': 2, 'o': 1}

Watch the full Video tog get solutions
#python #program #solution #coding #learnpython
#counter #frequency #deepak.j

Рекомендации по теме
Комментарии
Автор

Is from this program
str=input('enter a string:')
dict={}
for i in str:
if i in dict:
dict[i]+=1
else:
dict[i]=1
print(dict)

copshubham
Автор

why print(dict) does not output only the count of the last letter.
how does it output all the letters .??

kushalsapkota
Автор

Great video .
if you don't want it to count spaces add :
elif x == " ":
pass

wolverin
Автор

I have an question how can I message you privately?

ivanbuniel
Автор

Bro I didn't understand dict[x] + = 1
dict[x] = 1

vinvinith