programming-examples/python/Dictionary/Python program to sort a dictionary by key.py

7 lines
213 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
color_dict = {'red':'#FF0000',
'green':'#008000',
'black':'#000000',
'white':'#FFFFFF'}
for key in sorted(color_dict):
print("%s: %s" % (key, color_dict[key]))