human
Sum of XOR of all sub | Sum of XOR of all K length sub - array of an array.
If the length of the array is less than k.
Array that will store xor values of subarray from 1 to i.
Traverse through the array.
If i is greater than zero , store xor of all the elements from 0 to i.
If it is the first element.
If i is greater than k.
Xor of values from 0 to i.
Now to find subarray of length k that ends at i , xor sum with x [ i - k ].
Add the xor of elements from i - k + 1 to i.
Return the resultant sum.
.
Driver code"
How can the above be solved in Python?

Can you provide a code to sum of XOR of all sub and the other steps required?
assistant
#Here is code to sum of XOR of all sub and the other steps required.
 def FindXorSum ( arr , k , n ) :
	if ( n < k ) :
		return 0 ;
	x = [ 0 ] * n ;
	result = 0 ;
	for i in range ( n ) :
		if ( i > 0 ) :
			x [ i ] = x [ i - 1 ] ^ arr [ i ] ;
		else :
			x [ i ] = arr [ i ] ;
		if ( i >= k - 1 ) :
			sum = 0 ;
			sum = x [ i ] ;
			if ( i - k > - 1 ) :
				sum ^= x [ i - k ] ;
			result += sum ;
	return result ;
arr = [ 1 , 2 , 3 , 4 ] ;
n = 4 ; k = 2 ;
print ( FindXorSum ( arr , k , n ) ) ;