Перейти к содержанию

Python zip() built-in function

Python zip() built-in function

From the Python 3 documentation Iterate over several iterables in parallel, producing tuples with an item from each one.

Examples

>>> furniture = ['table', 'chair', 'rack', 'shelf']
>>> price = [100, 50, 80, 40]
>>>
>>> for item, amount in zip(furniture, price):
...     print(f'The {item} costs ${amount}')
# The table costs $100
# The chair costs $50
# The rack costs $80
# The shelf costs $40