The following Python List Comprehension statement could be rephrased as the for loop below.
>>> [(x,y) for x in range(5) if x % 2 == 0 for y in range(5) if y % 2 == 1]
>>> result = []
>>> for x in range(5):
if x % 2 == 0:
for y in range(5):
if y % 2 == 1:
result.append((x,y))
I'm having hard time understanding the following two list comprehension expressions.
What is the equivalent for loop(easier to read) way of expressing them?
[(min([row[i] for row in rows]),max([row[i] for row in rows]))
for i in range(len(rows[0]))]
[[random.random()*(ranges[i][1]-ranges[i][0])+ranges[i][0]
for i in range(len(rows[0]))] for j in range(k)]