zip attribute in python code example
Example 1: zip python
number_list = [1, 2, 3]
str_list = ['one', 'two', 'three']
result = zip()
result_list = list(result)
print(result_list)
result = zip(number_list, str_list)
result_set = set(result)
print(result_set)
>>>[]
{(2, 'two'), (3, 'three'), (1, 'one')}
Example 2: python zip function
>>> letters = ['a', 'b', 'c']
>>> numbers = [0, 1, 2]
>>> for l, n in zip(letters, numbers):
... print(f'Letter: {l}')
... print(f'Number: {n}')
...
Letter: a
Number: 0
Letter: b
Number: 1
Letter: c
Number: 2