zip() 함수란 여러 순회 가능한 iterable 객체를 인자로 받아온 후 각 객체 안의 원소를 tuple 형태로 차례로 접근할 수 있는 반복자 (iterator)를 반환.
coffees = ['아메리카노', '카페라떼', '카페모카', '바닐라라떼', '핸드드립', '콜드브루']
prices = [4100, 4600, 4600, 5100, 6000, 5000]
for coffee, price in zip(coffees,prices):
print(coffee)
출력값
'아메리카노'
'카페라떼'
'카페모카'
...
for pair in zip(coffees,prices):
print(pair)
출력값
('아메리카노', 4100)
('카페라떼',4600)
...
'python' 카테고리의 다른 글
colab 에서 Plotly 가 안보이는 경우 (0) | 2023.01.18 |
---|---|
enumerate() 함수 (0) | 2022.08.26 |
엑셀 파일 / data 가공 (0) | 2022.08.26 |
Pandas 와 Dataframe (0) | 2022.08.25 |
딕셔너리 (Dictionary) (0) | 2022.08.25 |