def solution(my_string):
    alpa = []

    for i in range(65, 91):
        alpa.append(chr(i))
    for i in range(97,123):
        alpa.append(chr(i))
    # alpa : [A,B,C,D, ....Z, a, b, c, d, ...., z]
    
    result = []
    for item in alpa:
        result.append(my_string.count(item))
    return result

https://school.programmers.co.kr/learn/courses/30/lessons/181902

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

설명

A~Z, a~z까지 alpa라는 리스트에 추가를 먼저했다.

그리고 alpa리스트안에 알파벳을 각 순회하면서 count함수를 사용해서 result라는 함수에 추가했다.

+ Recent posts