上QQ阅读APP看书,第一时间看更新
The sum, max, and min functions
These functions are pretty much self-explanatory: they will try to summarize or compare values in iterables. Just remember that for the dictionary, its keys—not values—will be used:
sum({1:'A', 2:'B'})
>>> 3
Note that min and max don't require elements to be integers or floats:
max({'A':1, 'B':2})
>>> 'B'