[백준] 10808번: 알파벳 개수

jooo·2023년 1월 13일
0

백준

목록 보기
17/35
post-thumbnail

💻 문제 - B4


👉 제출 코드

  • 아스키코드 A~Z: 65~90, a~z: 97~122
  • ord(문자): 문자에 맞는 아스키 코드 값 변환
  • chr(숫자): 아스키 코드 값 숫자에 맞는 문자 반환

case1

S = list(input())
cnt = [0 for _ in range(26)]
for i in S:
    cnt[ord(i)-97] += 1
for i in cnt:
    print(i, end=' ')

case2

S = list(input())
cnt = [0] * 26
for i in S:
    cnt[ord(i)-ord('a')] += 1
print(*cnt)
profile
조금씩, 꾸준히, 자주

0개의 댓글