Coding/Python

[python]map 함수

후__아 2024. 3. 14. 12:13

 

※ map(function, iterable)

iterable 데이터 요소들에 function을 적용

# 백준 10869
a, b = input("").split()
print(int(a) + int(b))

# map 활용
a, b = map(int, input().split())
print(a + b)

 

# 프로그래머스 lv0 배열 원소의 길이
["we", "are", ...] => [2, 3, ...]
def solution(strlist):
    return [len(i) for i in strlist]
    # return list(map(len, strlist))