Hi all. I'm having a bit of trouble (maybe it's easier than I think..) finding the lowest and highest number in a tuple of lists. Here is my main tuple:

list_of = ([0,7],[100,25],[150,59],[300,189])

so pretty much, I need python to return the lowest and highest number for each 'item' in each list compared to the other lists of the same position (sorry if i word it hard to understand) so it would return something like this:

# lowest numbers:
for item in list_of:
    if list_of.find(item)==0:
        # somehow make a separate list and compare all of those numbers, returning which is highest and which is lowest. also repeat for 2nd item in list

print "lowest number in all lists (position 0): 0"
print "highest number in all lists (position 0): 300"
print "lowest number in all lists (position 1): 7"
print "highest number in all lists (position 1): 189"

there ya go. Again sorry if my question is hard to understand. thanks in advanced!

Not quite sure what You mean,but here are som min/max method that can help

>>> a = min([0,7],[100,25],[150,59],[300,189])
>>> a
[0, 7]
>>> b = min(a)
>>> b
0

>>> c = max([0,7],[100,25],[150,59],[300,189])
>>> c
[300, 189]
>>> d = max(c)
>>> d
300

#same with max
>>> list_of = ([0,7],[100,25],[150,59],[300,189])
>>> for item in list_of:
	min(item)
	
0
25
59
189

>>> list_of = ([0,7],[100,25],[150,59],[300,189])
>>> def flatten(list_of):
	for item in list_of:
		for element in item:
			yield element
			
>>> a = list(flatten(list_of))
>>> a
[0, 7, 100, 25, 150, 59, 300, 189]
>>> print min(a), max(a)
0 300
>>>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.