Python Dictionary get() Method

Python Dictionary get() Method

  • The get() method returns the value for the specified key if key is in dictionary.

Syntax

  • dictionary.get(keyname, value) 

Parameter Values

The get() method takes maximum of two parameters:

  • key - key to be searched in the dictionary
  • value (optional) - Value to be returned if the key is not found. The default value is None.


 

 

 

 

Comments