Zip function demo: returns a list of tuples : zip « Buildin Function « Python






Zip function demo: returns a list of tuples

Zip function demo:  returns a list of tuples
D1 = {}
D1['spam']  = 1
D1['eggs']  = 3
D1['toast'] = 5

keys = ['spam', 'eggs', 'toast']
vals = [1, 3, 5]

print zip(keys, vals)


           
       








Related examples in the same category

1.Generator ExpressionsGenerator Expressions
2.Loop over two or more sequences at the same timeLoop over two or more sequences at the same time
3.Zip a two listsZip a two lists
4.Read element in a zipped listRead element in a zipped list
5.Zip three tuplesZip three tuples
6.Difference between zip and mapDifference between zip and map