[프로그래머스] LV.0 배열 원소의 길이 / 파이썬(Python)

디딧·2022년 11월 19일

프로그래머스

목록 보기
29/36
post-thumbnail

문제 설명

문자열 배열 strlist가 매개변수로 주어집니다. strlist 각 원소의 길이를 담은 배열을 retrun하도록 solution 함수를 완성해주세요.

제한사항

1 ≤ strlist 원소의 길이 ≤ 100
strlist는 알파벳 소문자, 대문자, 특수문자로 구성되어 있습니다.

풀이1

def solution(strlist):
    answer = []
    for i in strlist:
        answer.append(len(i))
    return answer

풀이2

def solution(strlist):
    return [len(i) for i in strlist]
profile
M.S. in Statistics, 2022 - present

0개의 댓글