파이톨치

[백준] 1213 파이썬 본문

카테고리 없음

[백준] 1213 파이썬

파이톨치 2023. 3. 2. 17:14
728x90
from string import ascii_uppercase

alphabet_dict = {}

for i in ascii_uppercase:
	alphabet_dict[i] = 0

# print(alphabet_dict)

s = input()
for i in range(len(s)):
  alphabet_dict[s[i]] += 1

# print(alphabet_dict)
answer = ""
check = 0
mid = ""
for i in ascii_uppercase:
  if alphabet_dict[i]%2==0:
    alphabet_dict[i] -= 2
    while alphabet_dict[i]>=0:
      answer += i
      alphabet_dict[i] -= 2
  # 홀수인 경우
  else:
    if check == 1:
      check += 1
      break
    check = 1
    alphabet_dict[i] -= 2
    while alphabet_dict[i]>=0:
      answer += i
      alphabet_dict[i] -= 2
    mid = i

if check == 2:
  print("I'm Sorry Hansoo")
else:      
  print(answer + mid + answer[::-1])
728x90