human
Find sum in range L to R in given sequence of integers | Function to find the sum within the given range.
generating array from given sequence.
calculate the desired sum.
return the sum.
initialise the range"
How can the above be solved in Python?
 What is a code to find sum in range L to R in given sequence of integers and the other steps required?
assistant
#Here is code to find sum in range L to R in given sequence of integers and the other steps required.
 def findSum ( L , R ) :
	arr = [ ]
	i = 0
	x = 2
	k = 0
	while ( i <= R ) :
		arr . insert ( k , i + x )
		k += 1
		if ( i + 1 <= R ) :
			arr . insert ( k , i + 1 + x )
		k += 1
		x *= - 1
		i += 2
	sum = 0
	for i in range ( L , R + 1 ) :
		sum += arr [ i ]
	return sum
L = 0
R = 5
print ( findSum ( L , R ) )