For instance, say:

#create two dictionaries

c = {'gaurav':'patel','nilesh':'khan','ramesh':'sawant','anu':'marathe'}

d = {'amit':'waghe','swapnil':'salvi','anish':'mane','raghu':'ranjan'}

#then apply zip

d1 = zip(c,d)

print "D1 goes here"

print d1

The output is :

[('nilesh', 'amit'), ('ramesh', 'raghu'), ('gaurav', 'anish'), ('anu', 'swapnil')]

I do not understand how the pairing works in dictionaries.

In lists, it creates a zipped list with [(a1, b1, c1, ...,n1), ..., (ai, bi, ci, ...., ni),]

How is this decided in for python dictionary?

Similar questions and discussions