"""
功能:单词按照首字母分类
作者:zlw
日期:2021年12月4日
"""
words = ['apple','book','bar','hat','at','blade','matrix','not','auto','node','have','bad','mummy','native','hot','nation','brain']
map = {}
for word in words:
start_letter = word[0]
map.setdefault(start_letter,[]).append(word)
print(map)
for key in map.keys():
print('{}:{}'.format(key,map[key]))
结果如下: