0

Help with letter counter project - Py

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. That's the project. To be honest. I was a sponge when it comes to the python beginner course but now I'm struggling to understand how to use sets, dictionaries, lists and tuples. So the above project is a little tricky for me. text = input() Dictionary = {} What's next? Do I put a for loop in the dictionary to organise keys and values? How do I do that?

20th Apr 2022, 9:41 AM
Murtadah Al Shammary
Murtadah Al Shammary - avatar
8 Answers
+ 3
using a loop traverse each character from input string,.. if dict has the key of current character, then just increase its value at that key.. If dict has no key, then create a key and assign value 1 . That's it. Ex: "abca" Dict : 'a':2 , 'b':1, 'c':1 Before this, revise dictionary lesson again.. edit: Murtadah Al Shammary here it is complete steps.. what else hint you need? read once again get back with your try if not solved..
20th Apr 2022, 10:15 AM
Jayakrishna šŸ‡®šŸ‡³
+ 3
please show us your codešŸ‘‡šŸ‘‡šŸ‘‡
20th Apr 2022, 9:54 AM
NonStop CODING
NonStop CODING - avatar
+ 1
Obviously it is a very common task. You may assume, that python can do it . Actually the module collections can do it (google is your best friend until you are experienced enough to have it all in your mind) import collections help(collections) Is a good start to dive deeper into your topic. You will find, what u need and also other funny stuff. I recommend to use python standard whenever possible.
20th Apr 2022, 11:11 AM
Oma Falk
Oma Falk - avatar
21st Apr 2022, 4:04 AM
mohammed shibli
mohammed shibli - avatar
0
A hint please. I'll get back to you if I need more
20th Apr 2022, 2:27 PM
Murtadah Al Shammary
Murtadah Al Shammary - avatar
- 1
Try for loop through input string (text).
20th Apr 2022, 2:33 PM
Š Š¾Š¼Š°Ń€Šø
Š Š¾Š¼Š°Ń€Šø  - avatar
- 1
A hint
20th Apr 2022, 5:19 PM
Mary Rian
Mary Rian - avatar
- 2
You need a solution or just a hint?
20th Apr 2022, 12:16 PM
Š Š¾Š¼Š°Ń€Šø
Š Š¾Š¼Š°Ń€Šø  - avatar