Python Dictionary keys() Method
Example
Return Keys:
car = { "brand": "Porsche", "model": "911", "year": 1963 } x = car.keys() print(x)
Definition and Usage
The keys() method returns a view object. This view object contains a list of dictionary keys.
The view object will reflect any changes to the dictionary, please see the following example.
Syntax
dictionary.keys()
Parameter Value
No Parameters
More Examples
Example
When adding items to the dictionary, the view object is also updated:
car = { "brand": "Porsche", "model": "911", "year": 1963 } x = car.keys() car["color"] = "white" print(x)