Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Access Nested Dictionary Items with .get()

# key present
print(D['emp1'].get('name'))
# Prints Bob

# key absent
print(D['emp1'].get('salary'))
# PrintsNone
Source by www.learnbyexample.org #
 
PREVIOUS NEXT
Tagged: #Access #Nested #Dictionary #Items
ADD COMMENT
Topic
Name
9+2 =