YUYANE

Python / map() 본문

Programming Languages/PYTHON

Python / map()

YUYA 2021. 2. 18. 20:52

map 함수 

- map(function, iterable)

- 두 번째 인자(iterable)의 각 요소에 첫 번째 인자인 함수(function)를 적용하여 반환한다.

 

map 함수 사용 예시

(출처 : www.geeksforgeeks.org/python-map-function/)

def addition(n): 
    return n + n 
  
numbers = (1, 2, 3, 4) 
result = map(addition, numbers) 
print(list(result)) 

결과 : [ 2, 4, 6, 8]

 

 

 

참고

docs.python.org/3/library/functions.html#map

 

Comments