0
how to add letters as keys in an empty dic when the input is a text
7 odpowiedzi
+ 2
Can you please give an example? Like, what is the dictionary supposed to look like in respect to a given text?
+ 2
You could approach it like this:
* create an empty dict and iterate the string by letter (for-loop)
* for each letter, check if it is already in the dict
* if not, add it as key to the dict with the value 1
* if yes, update the value and increase if by one
+ 1
Follow the approach that I have outlined. Go through it step by step.
You can show us your updated code and we'll check on it.
+ 1
For new users the messaging feature unlocks after a few weeks, you just need to wait a little longer. :)
Post in this thread, so everyone can help you!
0
like if the input is "hello"
and i want the output to be like this
{h:1,e:2,l:2,o:1}
i want to know how many times each letter appears
0
why can't i send u a message
- 2
can u complete this code for me
text=input()
dict={}