「abbbd cdda cbaa」のような文字列が与えられた場合、「b」のような特定の文字の出現頻度が最も高い単語をどのように判断しますか。私の初期コード:
sample = "abbbd cdda cbaa"
sample_splitter = sample.split()
#sample_splitter is now [abbbd, cdda, cbaa]
for word in sample_splitter:
word.count("b") #this returns the number of occurrences of the char b
max(word.count("b")) #this will return the highest number
文字の最大数とそれに関連付けられている配列値を関連付ける方法を理解するのに苦労しています。この場合、それは「abbbd」でなければなりません