How to sum columns of an array in Python

前端 未结 12 1265
抹茶落季
抹茶落季 2021-01-04 09:58

How do I add up all of the values of a column in a python array? Ideally I want to do this without importing any additional libraries.

input_val = [[1, 2, 3,         


        
12条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-04 11:04

    I think this is the most pythonic way of doing this

    map(sum, [x for x in zip(*input_val)])
    

提交回复
热议问题