본문 바로가기

PYTHON LANGUAGE

ZIP (aggregate two iterators as list of tuples)

numbers = [1, 2, 3]
letters = ["A", "B", "C"]
print(list(zip(numbers,letters))) # list of tuples 

for pair in zip(numbers, letters): 
    print(pair)

OUTPUT: 

[(1, 'A'), (2, 'B'), (3, 'C')]

 

(1, 'A')
(2, 'B')
(3, 'C')

'PYTHON LANGUAGE' 카테고리의 다른 글

2D Array  (0) 2022.06.25
ITERTOOLS  (0) 2022.06.20
Sort  (0) 2022.06.19
DICTIONARY  (0) 2021.12.15