Access Values From Sub Dictionary Python Code Example


Example 1: Nested dictionary Python

IDs = ['emp1','emp2','emp3']  EmpInfo = [{'name': 'Bob', 'job': 'Mgr'},            {'name': 'Kim', 'job': 'Dev'},            {'name': 'Sam', 'job': 'Dev'}]  D = dict(zip(IDs, EmpInfo))  print(D) # Prints {'emp1': {'name': 'Bob', 'job': 'Mgr'}, #         'emp2': {'name': 'Kim', 'job': 'Dev'}, #         'emp3': {'name': 'Sam', 'job': 'Dev'}}

Example 2: Nested dictionary Python

D = {'emp1': {'name': 'Bob', 'job': 'Mgr'},      'emp2': {'name': 'Kim', 'job': 'Dev'},      'emp3': {'name': 'Sam', 'job': 'Dev'}}

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable