これがあなたが望むものであるかどうかはわかりませんが、これにより、最も頻繁なキャラクターが発生の数に続いて印刷されます。
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)
これは、最も頻繁なキャラクターと発生数のタプルを返します。
collections.Counter(stringToData).most_common(1)[0]
#output: for example: ('f', 5)
例:
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)
出力は次のとおりです。
In your string, the most frequent character is f, which occurred 8 times