【发布时间】:2014-11-24 18:23:28
【问题描述】:
我正在尝试创建一个histogram 函数,该函数接受字符串并计算字符串被使用并放入字典的次数。我还在学习 Python,所以任何提示都会有所帮助。
>>> histogram('The Goose that Laid the Golden Egg')
{'l': 2, 'n': 1, 'o': 3, 'h': 3, 'i': 1,'d': 2, 'e': 5, 'g': 4, ' ': 6, 'a': 2, 't': 4, 's': 1}
【问题讨论】:
标签: python dictionary histogram