Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Create index-to-value mapping in a dictionary based on a list of values

  • zip
  • dict
planned_order = ('b', 'c', 'd', 'a')
plan = dict(zip(range(len(planned_order)), planned_order))
print(plan)

Output:

{0: 'b', 1: 'c', 2: 'd', 3: 'a'}