Determining Letter Frequency Of Cipher Text

后端 未结 3 766
我寻月下人不归
我寻月下人不归 2020-12-01 22:38

I am trying to make a tool that finds the frequencies of letters in some type of cipher text. Lets suppose it is all lowercase a-z no numbers. The encoded message is in a t

3条回答
  •  渐次进展
    2020-12-01 23:20

    The modern way:

    from collections import Counter
    
    string = "ihavesometextbutidontmindsharing"
    Counter(string)
    #>>> Counter({'i': 4, 't': 4, 'e': 3, 'n': 3, 's': 2, 'h': 2, 'm': 2, 'o': 2, 'a': 2, 'd': 2, 'x': 1, 'r': 1, 'u': 1, 'b': 1, 'v': 1, 'g': 1})
    

提交回复
热议问题