0
0

文章の中でどの文字が一番登場したのかを判定するやつ

Posted at
main.py

# 与えられたテキスト
text = "Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'"
alphabet = [["air",1]]

for i in text:
    judge_num = 0
    for num in alphabet:
        if str(i) == str(num[0]):
            num_1 = num[1]
            num[1] = int(num_1) + 1
            judge_num = 1
            break
    if judge_num == 0:
        alphabet.append([str(i),1])

alphabet_num_base_num = 0
alphabet_num_base_name = ""
for alphabet_name , alphabet_num in alphabet:
    if alphabet_name == "," or alphabet_name == " " or alphabet_name == "." :
        pass
    else:
        if alphabet_num_base_num <= alphabet_num :
            alphabet_num_base_num = alphabet_num
            alphabet_num_base_name = alphabet_name
        
print(alphabet)
print("_________________")
print(alphabet_num_base_name)
print(alphabet_num_base_num)



0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0