Je ne sais pas si c'est ce que vous voulez, mais cela imprimera le personnage le plus fréquent suivi avec le nombre d'occurrences:
import collections
char, num = collections.Counter(stringToData).most_common(1)[0]
print "In your string, the most frequent character is %s, which occurred %d times" % (char, num)
Cela renvoie un tuple du caractère le plus fréquent et du nombre d'occurrences.
collections.Counter(stringToData).most_common(1)[0]
#output: for example: ('f', 5)
Exemple:
stringToData = "aaa bbb ffffffff eeeee"
char, num = collections.Counter(stringToData).most_common(1)[0]
print "In your string, the most frequent character is %s, which occurred %d times" % (char, num)
La sortie est:
In your string, the most frequent character is f, which occurred 8 times