- 입력한 단어를
upper()
를 통해 대문자로 바꿔준다.set
을 사용해서 중복값을 제거한다.- count 숫자를 리스트에
append
한다.- 숫자 최대값이 중복되면 물음표를 출력하고 그렇지 않으면 많이 사용된 알파벳을 출력한다.
# 백준 Bronze1 - 1157(단어 공부)
# 문제링크: https://www.acmicpc.net/problem/1157
word = input().upper()
word_list= list(set(word))
cnt=[]
for i in word_list:
count = word.count
cnt.append(count(i))
if cnt.count(max(cnt))>1:
print("?")
else:
print(word_list[(cnt.index(max(cnt)))])
파이썬의 메소드를 사용해서 비교적 쉽게 해결할 수 있었던 것 같다.