Programming/Python & Data Structures
[Baekjoon/Python3] 1157번 단어 공부
HooNeee
2020. 12. 2. 23:02
[Baekjoon/Python3] 1157번 단어 공부
1157번: 단어 공부
알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다.
www.acmicpc.net
word = list(input().upper())
alp = list(set(word))
list_cnt = []
for i in alp:
list_cnt.append(word.count(i))
if list_cnt.count(max(list_cnt)) > 1:
print('?')
elif list_cnt.count(max(list_cnt)) == 1:
idx = list_cnt.index(max(list_cnt))
print(alp[idx])