Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get key value in nested dictionary python

def recursive_items(dictionary):
    for key, value in dictionary.items():
        if type(value) is dict:
            yield from recursive_items(value)
        else:
            yield (key, value)

a = {'a': {1: {1: 2, 3: 4}, 2: {5: 6}}}

for key, value in recursive_items(a):
    print(key, value)
Comment

how to print a value of a key in nested dictionary python

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

print(D['emp1']['name'])
# Prints Bob

print(D['emp2']['job'])
# Prints Dev
Comment

print nested dictionary values in python

for account in bank_dictionary:
    print("
 ACCOUNT: ", account)
    for subaccount in bank_dictionary[account]:
        print("
 Subaccount: ", subaccount)
Comment

PREVIOUS NEXT
Code Example
Python :: NumPy bitwise_and Syntax 
Python :: python load file with multiple jsons 
Python :: how to remove last item from list python 
Python :: python use variable name as string 
Python :: get table wikipedia 
Python :: bash escape double quote windows batch 
Python :: import one file into another python 
Python :: best python books python 3 
Python :: create QAction with icon in pyqt 
Python :: python increase one item in list 
Python :: how to get csv file first row first column value in python 
Python :: with torch.no_grad() if condition 
Python :: chat application in python 
Python :: python last index of item in list 
Python :: enormous input test codechef solution 
Python :: how to make every item compare the rest items of list in python 
Python :: Adding a new column in pandas dataframe from another dataframe with different index 
Python :: programmation orienté objet python 
Python :: python how to make a png 
Python :: how to do input python 
Python :: os.filename 
Python :: variable globale python 
Python :: looping over lists in python 
Python :: pyqt math 
Python :: matlab .* operator in python 
Python :: get n largest values from 2D numpy array matrix 
Python :: set remove in python 
Python :: cv2 assertion failed 
Python :: python split string by specific word 
Python :: max value of a list prolog 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =