Non sono sicuro che questo sia quello che vuoi, ma questo stamperà il carattere più frequente seguito dal numero di occorrenze:
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)
Ciò restituisce una tupla del carattere più frequente e il numero di occorrenze.
collections.Counter(stringToData).most_common(1)[0]
#output: for example: ('f', 5)
Esempio:
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)
L'output è:
In your string, the most frequent character is f, which occurred 8 times