Python - Create dictionaries via dict and zip function

Introduction

We can make dictionaries by passing to the dict type name either keyword arguments, or the result of zipping together sequences of keys and values obtained at runtime.

Both the following make the same dictionary:

Demo

bob1 = dict(name='Bob', job='dev', age=40)                      # Keywords 
print( bob1 )
bob2 = dict(zip(['name', 'job', 'age'], ['Bob', 'dev', 40]))    # Zipping 
print( bob2 )

Result

Mappings are not ordered.

Related Topic