Get the App
SLTechnology News&Howtos  ›  Development  › 

How to find the largest and smallest list elements in python

Shulou Source: shulou.com Published: 2022-06-01 05:43:00 11月15日 Update

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!

Tags: Articles maximum minimum elements value interest at the same time more friends knowledge editing industry information information channels channels reference learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info macOS MySQL Shulou Information