Function Details: keys

Description


Returns a new view of the dictionary's keys.


Extended Description


The keys() method returns a view object that contains all the keys in the dictionary. This view object is dynamic, meaning it reflects any changes made to the dictionary. The keys view supports set operations when compared to other views, making it useful for comparing dictionaries. In Python 3, dict_keys objects are not directly subscriptable, but can be easily converted to a list if needed.


Function Signature


dict.keys() -> dict_keys

Module: dict

Class: dictionary

Parameters



Return


Returns a dict_keys object, which is a view of the dictionary's keys.


Return Type


dict_keys

Output

Explanation

This example shows how to use keys() and convert the result to a list.