"리스트 컴프리헨션"의 두 판 사이의 차이

48번째 줄: 48번째 줄:
# [('spade', 1), ('spade', 2), ('heart', 1), ('heart', 2), ('diamond', 1), ('diamond', 2), ('clover', 1), ('clover', 2)]
# [('spade', 1), ('spade', 2), ('heart', 1), ('heart', 2), ('diamond', 1), ('diamond', 2), ('clover', 1), ('clover', 2)]
</source>
</source>
|제목2 = PHP
|내용2 =
asd
}}
}}



2020년 7월 11일 (토) 19:24 판

1 개요

list comprehension
리스트 컴프리헨션, 리스트 캄프리헨션
  • 기존의 리스트를 이용하여 새로운 리스트를 만드는 방법
  • 기존의 리스트에 기반한 리스트를 만들기 위해 일부 프로그래밍 언어에서 사용 가능한 문법적 구조
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
squares = [x**2 for x in a]
print(squares)

2 예제

3 같이 보기

4 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}