# We define array simple_arr as a list whose elements are lists
simple_arr = [[34, 38, 50, 44, 39],
[42, 36, 40, 43, 44],
[24, 31 ,46 ,40 ,45],
[43, 47, 35, 31, 26],
[37, 28, 20, 36, 50]]
# Create a function to calculate the average
def mean_arr(arr_arg):
count_arr = 0
sum_arr = 0
# Loop through all array elements with counting the number and sum of elements
for row in arr_arg:
for elem in row:
count_arr += 1
sum_arr + = elem
res = sum_arr / count_arr
return res
print(mean_arr(simple_arr))
Comments
Dear Robert please try sum_arr += elem
uh yeah its wrong. fix it
Leave a comment