human
Sum of all odd length subarrays | Function to calculate the sum of all odd length subarrays.
Stores the sum.
Size of array.
Traverse the array.
Generate all subarray of odd length.
Add the element to sum.
Return the final sum.
Given array arr [ ].
Function call"
How can the above be solved in Python?

=====
Give me a code to sum of all odd length subarrays and the other steps required?
assistant
#Here is code to sum of all odd length subarrays and the other steps required.
 def OddLengthSum ( arr ) :
	sum = 0
	l = len ( arr )
	for i in range ( l ) :
		for j in range ( i , l , 2 ) :
			for k in range ( i , j + 1 , 1 ) :
				sum += arr [ k ]
	return sum
arr = [ 1 , 5 , 3 , 1 , 2 ]
print ( OddLengthSum ( arr ) )