Need max values in list of tuples, based on position
Dennis Lee Bieber
wlfraed at ix.netcom.com
Fri Nov 11 12:49:37 EST 2022
On Fri, 11 Nov 2022 02:22:34 -0500, DFS <nospam at dfs.com> declaimed the
following:
>
>[(0,11), (1,1), (2,1),
> (0,1) , (1,41), (2,2),
> (0,9) , (1,3), (2,12)]
>
>The set of values in elements[0] is {0,1,2}
>
>I want the set of max values in elements[1]: {11,41,12}
Do they have to be IN THAT ORDER?
>>> data = [(0,11), (1,1), (2,1), (0,1) , (1,41), (2,2), (0,9) , (1,3), (2,12)]
>>> reshape = list(zip(*data))
>>> result = sorted(reshape[1])[-3:]
>>> result
[11, 12, 41]
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
More information about the Python-list
mailing list