Posted on 10th September 2024|27 views
How to get dictionary keys as a list in python?
Posted on 10th September 2024| views
You can do it by using ditc.keys like this:
def getList(dict):
return dict.keys()
dict = {1:'how', 2:'are', 3:'you'}
print(getList(dict))
Output:
[1, 2, 3]