문자열이 입력되면 각 문자의 등장 횟수를 처음 등장한 순서대로 문자:개수 형식으로 출력하세요.
📥 테스트 입력값
level
🔎 실행 결과
l:2
e:2
v:1
💡 힌트 코치
딕셔너리와 순서 리스트를 함께 사용하세요.
✅ 정답 공개
text = input().strip()
counts = {}
order = []
for ch in text:
if ch not in counts:
counts[ch] = 0
order.append(ch)
counts[ch] += 1
for ch in order:
print(ch + ':' + str(counts[ch]))