Home

Published

- 1 min read

python average of two lists by row

img of python average of two lists by row

The solution for this is noted below

python average of two lists by row

Solution

   # Basic syntax:
[(a + b)/2 for a, b in zip(list_1, list_2)]

# Example usage:
list_1 = [1, 2, 3]
list_2 = [4, 5, 6]
[(a + b)/2 for a, b in zip(list_1, list_2)]
--> [2.5, 3.5, 4.5]

Try other methods by searching on the site. That is if this doesn’t work