Shiro
0
Q:

get all keys and values from dictionary python

# 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
# 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 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
d = {2:"hello"}
d.values()
0
a = {1:2 , 2:3 , 3:4}
values = a.values()
0

New to Communities?

Join the community