jub0bs
0
Q:

python list keys from dictionary

# Basic syntax:
list_of_keys = list(dictionary.keys())
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
# To get all the keys of a dictionary as a list, see below
newdict = {1:0, 2:0, 3:0}
list(newdict)
# Output:
# [1, 2, 3]
4
# 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

New to Communities?

Join the community