0
Count letters
I need to count how many times a letter appears in a word. For example, "hello" --> "l" = 2, "o" --> 1 etc... Can you please tell me the code logic
4 Answers
+ 2
I did a dict-comprehension with the .count() method as my value đ
but to rkk 's point, it is easier to help you, by you showing us, how to help you, we need to see your logic too.
+ 1
Okay.
Where's your attempt?
edit:
Code logics,
make a map.
traverse each letter.
If the letter is in map then increment its frequency else add new entry of the letter to the map.
sounds complex but it's easy and intuitive.
Happy coding.
0
there's a built-in utility class ready to return a dict like object in the module 'collections' ;P
https://docs.python.org/3/library/collections.html