Dear all,
I have a few lists. What's the best way of finding the maximum number of all
the lists.
For example,
[2,3,4],[1,2,3],[4,7]
The max is 7.
Thanks
Colin 6 2345
[[ This message was both posted and mailed: see
the "To," "Cc," and "Newsgroups" headers for details. ]]
What about :
m = max([max(i) for i in (list1, list2, list3, etc...)])
Example: max([max(i) for i in ([2,3,4], [1,2,3], [4,7])])
7
/Jean Brouwers
ProphICy Semiconductor, Inc.
In article <c7**********@ucsnew1.ncl.ac.uk>, C GIllespie
<cs******@hotmail.com> wrote:
Dear all,
I have a few lists. What's the best way of finding the maximum number of all the lists.
For example,
[2,3,4],[1,2,3],[4,7]
The max is 7.
Thanks
Colin
"C GIllespie" <cs******@hotmail.com> wrote in message
news:c7**********@ucsnew1.ncl.ac.uk... Dear all,
I have a few lists. What's the best way of finding the maximum number of
all the lists.
For example,
[2,3,4],[1,2,3],[4,7]
The max is 7.
Sidestepping 'best' which may depend on context, a general 'good' way is lists = [2,3,4],[1,2,3],[4,7] max([max(l) for l in lists])
7
Terry J. Reedy
"C GIllespie" <cs******@hotmail.com> wrote in message news:<c7**********@ucsnew1.ncl.ac.uk>... Dear all,
I have a few lists. What's the best way of finding the maximum number of all the lists.
For example,
[2,3,4],[1,2,3],[4,7]
The max is 7.
Thanks
Colin l=[[2, 3, 4], [1, 2, 9], [4, 7]] max(map(max,l))
9 l=[[2, 3, 4], [1, 2, 9],[12], [4, 7]] max(map(max,l))
12
Regards
Peter
C GIllespie wrote: I have a few lists. What's the best way of finding the maximum number of all the lists.
For example,
[2,3,4],[1,2,3],[4,7]
The max is 7.
For arbitrarily nested sequences: def rmax(seq):
.... try:
.... return max(map(rmax, seq))
.... except TypeError:
.... return seq
.... rmax(1)
1 rmax([1,2])
2 rmax([[1,2], [3,4]])
4 rmax([[1,2], [3,44], 5, [6]])
44 rmax([[1,2], [[3,44], 5, [6]]])
44
Peter
"Terry Reedy" <tj*****@udel.edu> wrote in
news:ma**************************************@pyth on.org: Sidestepping 'best' which may depend on context, a general 'good' way is
lists = [2,3,4],[1,2,3],[4,7] max([max(l) for l in lists]) 7
Without any claims to better or worse, here is another option: l = [2,3,4],[1,2,3],[4,7] l
([2, 3, 4], [1, 2, 3], [4, 7]) max(itertools.chain(*l))
7
Dear All,
Thanks for all the responses.
Very helpful (again)
Colin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ago |
last post by:
Is it possible to have a default value associated python objects? I.e.
to flag an attribute in such a way that the assignment operator for the
object returns the default attribute instead of the...
|
by: Dave Hopper |
last post by:
Hi
I am using the following SQL to retrieve a value in a list box using a
unique ID held in the list box call cntID. The list box is used on an
order form to list appointments that have been...
|
by: Martyn Fewtrell |
last post by:
I want to update a database record with a number of fields - doesn't sound
to difficult at this stage!
I have a system to select the correct record from the database and load the
data into a...
|
by: Martin Ortiz |
last post by:
Ugh....
All classes are copy by reference, even if you use "ByVal" and NOT "ByRef"
it's still a copy by reference.
Of course, as a consequence, if you change any values of the object you
passed...
|
by: Mike Collins |
last post by:
I cannot get the correct drop down list value from a drop down I have on my
web form. I get the initial value that was loaded in the list.
It was asked by someone else what the autopostback was...
|
by: imrantbd |
last post by:
This is my first problem.Please help me.
I have the following code:
<head>
<script language="JavaScript">
function addSrcToDestList() {
destList1 = window.document.forms.destList;
srcList...
|
by: Johnny Jörgensen |
last post by:
Hi y'all
I've got a custom control that is inherited from a normal TextBox. To that,
I've added a new property that I call "Units", Which is a collection class
containing members of a "Unit"...
|
by: Amar |
last post by:
Hi,
I have a generic list with a some objects of a particular class in it.
I have implemented a IComparer for the the class and pass it to the
List.
The list.sort method works fine when the value...
|
by: Zytan |
last post by:
This returns the following error:
"Cannot modify the return value of
'System.Collections.Generic.List<MyStruct>.this' because it is
not a variable"
and I have no idea why! Do lists return copies...
|
by: zman77 |
last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine
Hi.
This is my first post, though I've "lurked" for a while because I find these forums very helpful....
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |