summing elements of a list of csv lists in python -


i have list of csv lists like:

[[0, 0], [0, 2], [1, 1], [2, 0], [0, 3], [1, 2], [2, 1], [3, 0]] 

what want sum each individual list i.e create new list composed of each comma seperated variable summed, , check if equal value i.e:

check [0+0,0+2,1+1,2+0..... equal number

i have gotten far as:

 if sum(gcounter)==3:    gamma=true    print(gamma)  else:    pass 

i have tried sum(int..., , tried using loop amongst others keeps throwing same error each time try different method typeerror: unsupported operand type(s) +: 'int' , 'list' problem sum function

trying work out has frankly left me feeling listless appreciate help!!!

are looking like:

>>> lst = [[0, 0], [0, 2], [1, 1], [2, 0], [0, 3], [1, 2], [2, 1], [3, 0]] >>> print ([x x in lst if sum(x) == 3]) [[0, 3], [1, 2], [2, 1], [3, 0]] 

essentially loop on lst getting 1 sublist @ time. sum sublist , if equals 3, keep sublist in output list.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -