VOOZH about

URL: https://www.geeksforgeeks.org/python/python-get-dictionary-keys-as-a-list/

⇱ Dictionary keys as a list in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Dictionary keys as a list in Python

Last Updated : 11 Jul, 2025

In Python, we will encounter some situations where we need to extract the keys from a dictionary as a list. In this article, we will explore various easy and efficient methods to achieve this.

Using list()

The simplest and most efficient way to convert dictionary keys to lists is by using a built-in list() function.


Output
['a', 'b', 'c']

Explanation:

  • a.keys() returns a dict_keys object, which is a view object.
  • Wrapping it with list() converts the view into a list.

Using List Comprehension

List Comprehension provide concise and readable way to create a list of keys.


Output
['a', 'b', 'c']

Explanation:

  • Iterating directly over the dictionary yields its keys.
  • This method avoids calling .keys() explicitly.

Using (* )Unpacking Operator

The unpacking operator (*) can be used to extract keys directly.


Output
['a', 'b', 'c']

Explanation:

  • The unpacking operator expands the dictionary keys into a list.

Using map()

map() function can be used to explicitly iterate over the dictionary.


Output
['a', 'b', 'c']

Explantion:

  • map() applies the identity function (or a custom function) to each key.
  • Converting the result to a list yields the desired keys.
Comment