[Python] lambda vs list comprehension
아래 두개는 동일한 표현식 결과도 같다. range(1,10)을 쓰면 [1,2,3,4,5,6,7,8,9]의 list를 반환한다. 요즘 추세는 list comprehension을 쓰는 trend. lambda를 쓰면 readability가 떨어진다고.... 1) Lambda>>> list(filter(lambda x:x%3==0, range(1,10))) [3, 6, 9] 2) list comprehension>>> [x for x in range(1,10) if x%3 == 0] [3, 6, 9]