I'm having trouble understanding the syntax here.
matrix_a = [[1, 2], [3, 4], [5, 6]]
matrix_b = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[a for a, b in matrix_a]
output: [1, 3, 5]
[a for b, a in matrix_a]
output: [2, 4, 6]
I understand a little about how list-comprehensions work, but I don't understand the syntax when accessing certain elements within a nested list.
I just can't wrap my head around this syntax. How is this syntax working? What does the comma represent? What does a for a
mean? Can you explain whats going on under the hood? And finally how would you do this with matrix_b