get all keys from dictionary python code example
Example 1: get all the keys in a dictionary python
dict1 = {1:'A', 2:'B', 3:'C'}
keysList = list(dict1.keys())
print(keysList)
valuesList = list(dict1.values())
print(valuesList)
Example 2: python list keys from dictionary
list_of_keys = list(dictionary.keys())
Example 3: python get dictionary keys
newdict = {1:0, 2:0, 3:0}
newdict.keys()
Example 4: python convert dict_keys to list
d = {1:1, 2:2, 3:3}
d_keys_list = list(d.keys())
Example 5: get all keys and values from dictionary python
for k,v in dict.items():
print(k, v)