본문 바로가기
Python

심화 연습 - 1157

by soojitasan 2024. 6. 26. 22:07
## 1157 단어 공부
word = input()
word = word.lower()  ## 대소문자 구분 X를 위한 처리
word_len = len(word)
alphabet_list = [chr(i) for i in range(ord('a'),ord('z')+1)]
alphabet_cnt = [0 for i in range (1, 27)]
alphabet_set = dict(zip(alphabet_list,alphabet_cnt))

for i in range (0, word_len):
  if word[i] in alphabet_set:
    alphabet_set[word[i]] = alphabet_set[word[i]] + 1

max_alphabet = [k for k, v in alphabet_set.items() if max(alphabet_set.values()) == v]
if len(max_alphabet) > 1:
  print('?')
else:
  print((''.join(max_alphabet)).upper())