Q:

get all keys from python dictionary in a list

# 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
#python 3
for k,v in dict.items():
    print(k, v)
1
# Python program to show working  
# of keys in Dictionary 
  
# Dictionary with three keys 
Dictionary1 = {'A': 'Geeks', 'B': 'For', 'C': 'Geeks'} 
  
# Printing keys of dictionary 
print(Dictionary1.keys()) 
  
# Creating empty Dictionary 
empty_Dict1 = {} 
  
# Printing keys of Empty Dictionary 
print(empty_Dict1.keys()) 
1
a = {1:2 , 2:3 , 3:4}
values = a.values()
0

New to Communities?

Join the community