Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get function in dictionary

#The get() method in  dictionary returns:
#the value for the specified key if key is in dictionary.
#None if the key is not found and value is not specified.
#value if the key is not found and value is specified.
# value is provided
print('Salary: ', person.get('salary', 0.0))
 
PREVIOUS NEXT
Tagged: #function #dictionary
ADD COMMENT
Topic
Name
6+9 =