728x90
๋ด๊ฐ ์ด ์ฝ๋
a = input().upper()
s = list(set(a))
count = []
for i in range(len(s)):
count.append(0)
for j in range(len(a)):
if(s[i] == a[j]):
count[i]+=1
max = 0
for i in range(0, len(count)):
if(count[max] < count[i]):
max = i
k = s[max]
for i in range(0, len(count)):
if (count[max] == count[i]) & (len(count) > 0) & (max != i):
k = "?"
print(k)
๋ค๋ฅธ ์ฌ๋์ด ์ด ์ฝ๋
n = input()
n = n.upper()
alpa='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
result = []
for i in alpa:
result.append(n.count(i))
if result.count(max(result)) > 1:
print("?")
else:
print(alpa[result.index(max(result))])
๋ถ์กฑํ ์
count, max, index ๋ฅผ ์ฌ์ฉํ์ผ๋ฉด ๋ ์ข์์ ๋ฏ
์์ ํ ์ฝ๋
a = input().upper()
s = list(set(a))
result = []
for i in s:
result.append(a.count(i))
if result.count(max(result)) > 1:
print("?")
else:
print(s[result.index(max(result))])
728x90