+ 2

Help plz....How to solve this?

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}

2nd Jan 2023, 2:37 PM
Imran Shakil
Imran Shakil - avatar
3 Respostas
+ 2
Thanks all...I had did it.
2nd Jan 2023, 3:38 PM
Imran Shakil
Imran Shakil - avatar
+ 7
You can approach the problem like this: * create an empty dictionary * loop over the string * if the current character is not in the dictionary keys, create a key with this character and give it the value 1 * if the character is already in the dictionary, add 1 to value of the corresponding key
2nd Jan 2023, 2:45 PM
Lisa
Lisa - avatar
+ 4
Imran Shakil We don't provide direct solution and you know why.
2nd Jan 2023, 3:35 PM
A͢J
A͢J - avatar