Python Dictionary get() method

The dictionary.get() method returns the value of the item with the specified key.

Syntax

Parameter

keyname- This parameter represents the key to be searched in the dictionary.

value- The parameter represents a value to return if the specified key does not exist and its default value none.

Return

This method returns the value for the specified key if the key is in dictionary else it returns none if the key is not found and value is not specified.

Example 1

Output

Example 2

Output

Pin It on Pinterest

Share This