Say I've a Python 2D list as below:
my_list = [ [1,2,3,4],
[2,4,5,6] ]
I can get the row totals with a list comprehension:
row_totals = [ sum(x) for x in my_list ]
Can I get the column totals without a double for
loop? Ie, to get this list:
[3,6,8,10]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…