Phaml Phaml - 4 months ago 39
Python Question

please delete my post thank you

unable to delete and the moderator refused to delete it


If you think about it, you are looping over the list and each iteration, x is holding the sub list. You then are getting index 1 of each sub list, which gives you the 2nd column.

Picture it this way:

1, 2, 3

4, 5, 6

7, 8, 9

The bolded items are the items that are accessed in each iteration, and put into a new list, giving you [2, 5, 8]

The expanded list comprehension equivalent is:

col2 = []
for x in m: