iNTERFACEWARE Products Manual > Learning Center > Learning Python > Dictionaries > Dictionaries and Loops |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
To obtain a list of the keys in a dictionary, use the keys() function. keys() can be used with the for statement to process each element of the dictionary in turn:
When you run this code, the output is similar to this:
Note that the elements of the dictionary are displayed in no particular order. To sort the keys in alphabetical order, use sort():
|