How do you get a list of all the keys in a dictionary in python?



How do you get a list of all the keys in a dictionary in python?..

Answer / Kum.anjali Singh

To get a list of all keys from a dictionary, use `list(dictionary.keys())`. For example:

```python
my_dict = {'a': 1, 'b': 2, 'c': 3}
keys = list(my_dict.keys())
print(keys) # Output: ['a', 'b', 'c']
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

How will you convert an integer to a hexadecimal string in python?

1 Answers  


What is egg and wheel in python?

1 Answers  


Explain python’s slice notation?

1 Answers  


When do you use list vs. tuple vs. dictionary vs. set?

1 Answers  


Should I learn c before python?

1 Answers  


Why does python print out none?

1 Answers  


Why do we use raw_input in python?

1 Answers  


Python list of lists, changes reflected across sublists unexpectedly

1 Answers  


What are the disadvantages of the Python programming language?

1 Answers  


Is python a nonetype?

1 Answers  


What is pip and pip freeze commands will do?

1 Answers  


What is set type in python?

1 Answers  


Categories