- Learn Python by Building Data Science Applications
- Philipp Kats David Katz
- 59字
- 2021-06-24 13:06:08
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'