[ create a new paste ] login | about

Link: http://codepad.org/cn0UFPrD    [ raw code | output | fork ]

Python, pasted on Nov 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
rows = [[1,2,3,4],[3,5,88,9],[4,55,-6,0],[0,34,22,1222]]
t1 = [(min([row[i] for row in rows]),max([row[i] for row in rows])) for i in range(len(rows[0]))]
print(t1)

# Easy loop
t2 = []
for i in range(len(rows[0])):
    innerElements = []
    for row in rows:
        innerElements.append(row[i])
    newTuple = ( min(innerElements),max(innerElements) )
    t2.append(newTuple)

print(t2)


Output:
1
2
[(0, 4), (2, 55), (-6, 88), (0, 1222)]
[(0, 4), (2, 55), (-6, 88), (0, 1222)]


Create a new paste based on this one


Comments: