How to query the number of repetitions of the same letter in a word using Python

You can use Python's built-in collectionsmodule and call its Counterfunction, which can calculate the number of repetitions of the same letter in a word, for example: ```python from collections import Counterword = 'mississippi' Counter(word)# Output:

Counter({'i': 4, 's': 4, 'p': 2, 'm': 1})

```

Guess you like

Origin blog.csdn.net/weixin_35756624/article/details/129523093