Yaya
0
Q:

get dictionary keys

# 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])
8
# Python program to get  
# dictionary keys as list 
  
def getList(dict): 
    return dict.keys() 
      
# Driver program 
dict = {1:'Geeks', 2:'for', 3:'geeks'} 
print(getList(dict)) 
2
d = {2:"hello"}
d.values()
0

New to Communities?

Join the community