0

can someone help me sum this two list. so first would be 10+1=11 then 20+2=22 then 30+3=33 and so on:

list1 = [[1,2],[3,4],[5,6]]
list2 = [[10,20],[30,40],[50,60]]

the output would be something like this:

list3[[11,22],[33,44],[55,66]]

1 Answer 1

1

here is a possible solution:

list1 = [[1,2],[3,4],[5,6]]
list2 = [[10,20],[30,40],[50,60]]


def sum(list1, list2):
    new_list=[]
    for i in range(len(list1)):
        new_list.append([list1[i][j]+list2[i][j] for j in range(len(list1[i]))])
    return new_list  

print(sum(list1,list2))

[[11, 22], [33, 44], [55, 66]] Thanks, and good python

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you!!! thats actually exactly what i needed!
Hi @AdamSmith if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.