Zip function in python returns a new tuple object where the first element of the tuple will be the combination of the first element of each iterator passed and so on.
e.g. list1 = [1,2,3]
list2 = [4,5,6]
print(tuple(zip(list1,list2)))
output:
((1,4),(2,5),(3,6))
e.g. list1 = [1,2,3]
list2 = [4,5,6]
print(tuple(zip(list1,list2)))
output:
((1,4),(2,5),(3,6))
No comments:
Post a Comment