I need to add every index of an unknown amount of lists together into one list.
An example of what I mean:
list_a = [1,2,3,4,5]
list_b = [2,4,6,8,10]
list_c = [3,6,9,12,15]
def sum_lists():
temp_list = []
for index in range(len(list_a)):
temp_list.append(list_a[index] + list_b[index] + list_c[index])
return temp_list
total = sum_lists()
The expected output of my example code would be:
total = [6,12,18,24,30]
How would I accomplish the summation of an unknown amount of lists, for example 20 lists? I won't have to do this addition over thousands of lists, but I wouldn't know how many lists I have to add initially.
Any help would be greatly appreciated. All of the lists will be of the same length.