# To get all the keys of a dictionary use 'keys()'
newdict = {1:0, 2:0, 3:0}
newdict.keys()
# Output:
# dict_keys([1, 2, 3])
dict={1:2,3:4}
list_of_keys=list(dict)
# output
# [1, 3]
d = {"a":0, "b":1, "c":2}
keys, values = [], []
for k, v in d.items():
keys.append(k)
values.append(v)
print(keys,values)
# Python program to get
# dictionary keys as list
def getList(dict):
list = []
for key in dict.keys():
list.append(key)
return list
# Driver program
dict = {1:'Geeks', 2:'for', 3:'geeks'}
print(getList(dict))
myDict = {
"message": "Hello Grepper!"
}
for key, value in myDict.items():
print(key) #Output: message
print(value) #Output: Hello Grepper!
d = {2:"hello"}
d.values()