[python] 백준 1157번 오답노트

김보현·2024년 6월 10일
0

PS

목록 보기
21/62

정답

word = list(input().upper())
what_word = list(set(word))
count_word = []

for i in what_word:
    count = word.count(i)
    count_word.append(count)

if count_word.count(max(count_word))>=2:
    print('?')
else:
    print(what_word[count_word.index(max(count_word))])

틀린이유

dictionary로 풀려고했는데, 그러면 count랑 index를 못써서 풀 수가 없었다.

상기

list.count(i): list에 i가 몇개있는지 세어준다.
list.append(i): list에 i를 더해준다.
list.index(i): list에서 i의 위치를 찾는다.

profile
Fall in love with Computer Vision

0개의 댓글

관련 채용 정보