-1
forループで最も使用されている文字を返すにはどうすればよいですか?ルーピング中に最も多く使われている文字を返す - Python
マイコード:
import string
def intefer_shift(encrypted_textfile, language):
index = 0
file_connector = open(encrypted_textfile,'r')
data = file_connector.read()
box =[]
data = data.lower()
file_connector.close()
times = 0
#this for loop is designed to count the number of times items appear in file
# this for loop is designed print each letter in the alphabet and tells how many times they appear
for letter in string.ascii_lowercase:
num = data.count(letter)
print(letter, ':', num)
intefer_shift('homework1.txt','English')
あなたの質問は完全にコードです。あなたの**質問**に実際に*質問*をお願いします。 –
辞書がどのように機能するか知っていますか?はいの場合は、1つを使用して文字を数えます。現代的な方法としては、[collections.Counter'](https://docs.python.org/3/library/collections.html#collections.Counter)があります。 – skrx