Dictionary setdefault() method

In Python Dictionary setdefault() method is used to return the value of a key, if its in the dictionary. If not, it inserts key with a value to the given dictionary.

Syntax:
There are 2 Parameters used in this method. key: shows the key to be searched in the dictionary. default_value: is inserted to the dictionary if the key is not in the dictionary.
Example:
#dictionary method

STUDENT = {'Name': 'Phillip', 'age': 21}

age = STUDENT.setdefault('age')
print('person = ',STUDENT)
print('Age = ',age)