코딩테스트

백준 1157번 코드

원띵재 2023. 7. 31. 11:44

사용 언어 : python

 

문제 백준 1157번 :

알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다.

 

풀이 : 

s = input()
s = s.upper()
word = list(set(s))
cnt = []

for x in word:
  tmp = s.count(x)
  cnt.append(tmp)

if cnt.count(max(cnt))>1:
  print("?")
else:
  print(word[cnt.index(max(cnt))])