알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다.
첫째 줄에 이 단어에서 가장 많이 사용된 알파벳을 대문자로 출력한다. 단, 가장 많이 사용된 알파벳이 여러 개 존재하는 경우에는 ?를 출력한다.
예제 입력1
Mississipi
예제 출력1
?
inputt = input()
inputt = inputt.casefold()
def find_max(string):
a_o_a = [0] * 26
max_occ = 0
max_a_index = 0
for char in string:
arr_index = ord(char) - ord('a')
a_o_a[arr_index] += 1
for index in range(len(a_o_a)):
a_occ = a_o_a[index]
if a_occ == max_occ:
max_a_index = "?"
if a_occ > max_occ:
max_occ = a_occ
max_a_index = index
if max_a_index == "?":
return max_a_index
else:
return chr(max_a_index + ord('a')).upper()
print(find_max(inputt))