Python 3 - dictionary keys() Method


Description

The method keys() returns a list of all the available keys in the dictionary.

Syntax

Following is the syntax for keys() method −

dict.keys()

Parameters

NA

Return Value

This method returns a list of all the available keys in the dictionary.

Example

The following example shows the usage of keys() method.

#!/usr/bin/python3

dict = {'Name': 'Zara', 'Age': 7}
print ("Value : %s" %  dict.keys())

Result

When we run above program, it produces the following result −

Value : dict_keys(['Age', 'Name'])
python_dictionary.htm
Advertisements