How to find the largest and smallest list elements in python
This article mainly introduces python how to find the maximum and minimum list elements, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
The largest and smallest list elements
> a = [random.randint (0100) for _ in xrange] > heapq.nsmallest (5, a) [3,3,5,6,8] > > heapq.nlargest (5, a) [100,100,99,98,98] Thank you for reading this article carefully. I hope the article "how to find the largest and smallest list elements of python" shared by the editor will be helpful to you. At the same time, I hope you will support it. Pay attention to the industry information channel, more related knowledge is waiting for you to learn!