This code will get all the keys of dictionary as list.
def GetDictKeys(MyDict):
KeysList = MyDict.keys()
print KeysList
Dict = {‘a’:1, ‘b’:2, ‘c’:3}
GetDictKeys(Dict)
Output:
>>> [‘a’, ‘c’, ‘b’]
This code will get all the keys of dictionary as list.
def GetDictKeys(MyDict):
KeysList = MyDict.keys()
print KeysList
Dict = {‘a’:1, ‘b’:2, ‘c’:3}
GetDictKeys(Dict)
Output:
>>> [‘a’, ‘c’, ‘b’]