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?
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..
+ 3
please show us your codeššš
+ 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.
0
A hint please. I'll get back to you if I need more
- 1
Try for loop through input string (text).
- 1
A hint
- 2
You need a solution or just a hint?