top of page

Python Tutorial

Public·1 member

What is python zip() function - Codersarts

The zip method lets us map the corresponding index of multiple containers so that we can use them using as a single unit.


Syntax:


zip(*iterables)

Example:



# Example: zip() function
  
emp = [ "tom", "john"] 
age = [ 32, 28] 
dept = [ 'HR', 'Accounts'] 
  
# call zip() to map values 
out = zip(emp, age, dept)
  
# convert all values for printing them as set 
out = set(out) 
  
# Displaying the final values  
print ("The output of zip() is : ",end="") 
print (out)

Output:

 {('tom', 32, 'HR'), ('john', 28, 'Accounts')}

For other top rated Codersarts python program links



For other top rated python program visit here


If you like Codersarts blog and looking for Assignment help,Project help, Programming tutors help and suggestion  you can send mail at contact@codersarts.com.


Please write your suggestion in comment section below if you find anything incorrect in this blog post 

11 Views
bottom of page