O'Reilly logo
  • Chris Kang thinks this is interesting:

bob2 = dict(zip(['name', 'job', 'age'], ['Bob', 'dev', 40]))

From

Cover of Learning Python, 5th Edition

Note

zip() returns a tuple (ie immutable list). Given multiple iterable list to zip() arguments, it takes element from each list and forms a list as a new element in the resulting tuple. It stops creating elements (made up of each elements in the provided argument lists) in the resulting list when the shortest list in the argument list is traversed. zip([1,2,3],["a","b"]) results in a new tuple{[1,"a"], [2,"b"]}. In this example, the resulting tuple from zip() call is passed into dict() call, it is converted into map.