Skip to Content
전문가를 위한 파이썬(2판)
book

전문가를 위한 파이썬(2판)

by 루시아누 하말류, 강권학
November 2024
Beginner to intermediate
1064 pages
25h 21m
Korean
Hanbit Media, Inc.
Content preview from 전문가를 위한 파이썬(2판)
72
1
데이터 구조체
...
(‘black’, ‘S’)
(‘black’, ‘M’)
(‘black’, ‘L’)
(‘white’, ‘S’)
(‘white’, ‘M’)
(‘white’, ‘L’)
>>> tshirts = [(color, size) for size in sizes
... for color in colors]
>>> tshirts
[(‘black’, ‘S’), (‘white’, ‘S’), (‘black’, ‘M’), (‘white’, ‘M’),
(‘black’, ‘L’), (‘white’, ‘L’)]
❶ 색깔 (
color
)과 크기(
size
)로 나열된 튜플 리스트를 생성한다.
for
루프를 중첩해 지능형 리스트와 똑같은 순서로 색깔과 크기 쌍의 튜플 리스트를 만든다.
❸ 먼저 크기순으로 나열하고 그 안에서 색상별로 나열하려면
for
문의 순서를 바꾸면 된다. 지능형 리스트
안에서 줄을 바꾸면 그 결과가 어떤 순서로 정렬될지 더 쉽게 예상할 수 있다.
[예제
1
-
1
]에서는 다음 표현식으로
13
가지 순위와
4
가지 종류로 구성된 총
52
장의 카드 한 벌
을 만들었다.
self._cards = [Card(rank, suit) for suit in self.suits
for rank in self.ranks]
지능형 리스트는 단지 리스트만 만들 수 있다. 다른 시퀀스를 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

전문가를 위한 리액트

전문가를 위한 리액트

테자스 쿠마르
고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트

Publisher Resources

ISBN: 9791169211772