0

Dictionary

how do I get data from a string and make it a dictionary so that it looks like this {letters, number of duplicate letters}

20th Feb 2022, 7:04 AM
misbahul fuad
misbahul fuad - avatar
3 Antworten
+ 6
A python solution message = " This is a small message designed 2 test the following count functions.\n\n These functions will count the number of words within this message, count all the letters, then break down the letters into consonants & vowels, and identify capital & lower case letters.\n\n Special characters, (punctuation, paranthesis, etc) are also counted.\n\n Why don't you test this against your own input? " #txt = message.split() # words txt = message # letters a = {key:txt.count(key) for key in txt} print(a)
20th Feb 2022, 9:15 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
use Counter Collection in python it will count amount of each letter in the string
20th Feb 2022, 7:56 AM
Roni Berlin
Roni Berlin - avatar
+ 1
Tq
20th Feb 2022, 9:23 AM
misbahul fuad
misbahul fuad - avatar