[백준1157_파이썬(python)] - 단어 공부
문제
sol
S = input().lower()
S_list = list(set(S))
cnt = []
for i in S_list:
count = S.count(i)
cnt.append(count)
if cnt.count(max(cnt))>=2:
print('?')
else:
print(S_list[cnt.index(max(cnt))].upper())
풀이
너무 까다로운 문제라서 다른사람의 풀이를 참고했다
아래는 내가 틀린 풀이인데 어디에서 틀린지 모르겠다 끄응..
import operator
S = input()
array = []
for i in S:
if (ord(i)>96):
array.append(ord(i)-32)
else:
array.append(ord(i))
check = {}
for i in array:
if str(i) in check:
k = int(check['{0}'.format(i)])
check['{0}'.format(i)] = str(k+1)
else:
check['{0}'.format(i)] = '1'
all_value = list(check.values())
all_value = sorted(all_value, reverse = True)
all_key = list(check.keys())
try:
if(all_value[0] == all_value[1]):
print("?")
else:
for i in all_key:
if(check[i] == all_value[0]):
print(chr(int(i)))
except:
print(chr(array[0]))
참고
https://wook-2124.tistory.com/257
Author And Source
이 문제에 관하여([백준1157_파이썬(python)] - 단어 공부), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@chestnut1044/백준1157파이썬python-단어-공부저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)