Copyright © tutorialspoint.com

# Python dictionary get() Method

## Description:

This class method return a value for the given key. If key is not available then return returns default value None.

## Syntax:

    dict.get(key, default=None)

## Parameters:

Here is the detail of parameters:

- key: Key to be searched in the dictionary.

- default: Value to be returned in case key does not exist.

## Example:

    #!/usr/bin/python

    dict = {'Name': 'Zara', 'Age': 7}

    print "Value : %s" %  dict.get('Age')
    print "Value : %s" %  dict.get('Sex', "Never")

This produces following result:

    Value : 7
    Value : Never

Copyright © tutorialspoint.com