python zip

Posted by w3diy - 2 months ago

Example 1: Python zip()

number_list = [1, 2, 3]
str_list = ['one', 'two', 'three']

# No iterables are passed
data = zip()

# Converting iterator to list
data_list = list(data)
print(data_list)

# Two iterables are passed
data = zip(number_list, str_list)

# Converting iterator to set
data_set = set(data)
print(data_set)