In Python the Dictionary get() Method is used to return the value for the specified key if key is in given dictionary.
Syntax:
There are two Parameters used in get() Method, key – key to being searched in the given dictionary. And value– used as Value to be returned if the key is not found. The default value is none.
Example:
# dictionary method STUDENT = {'Name': 'Phillip', 'Class': '10'} print('Name: ', STUDENT.get('Name')) print('Class: ', STUDENT.get('Class')) # not provided value print('Age: ', STUDENT.get('Age')) #provided value print('Age: ',STUDENT.get('Age', 21))