Python dict.get() Method
The get() method returns the value of the item with the specified
key.
Syntax
dictionary.get(keyname, value)
Parameters
| Parameter | Description |
|---|---|
keyname |
Required. The keyname of the item you want to return the value from |
value |
Optional. A value to return if the specified key does not exist. Default value None |
Return Value
The value of the item with the specified key.
Example
Using the get() method:
Output
Click Run to execute your code
Enjoying these tutorials?