human
Write me a code to decode a median string to the original string and the other steps required given the following:
Decode a median string to the original string | function to calculate the median back string.
length of string.
initialize a blank string.
Flag to check if length is even or odd.
traverse from first to last.
if len is even then add first character to beginning of new string and second character to end.
if current length is odd and is greater than 1.
add first character to end and second character to beginning.
if length is 1 , add character to end.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to decode a median string to the original string and the other steps required.
 def decodeMedianString ( s ) :
	l = len ( s )
	s1 = " "
	if ( l % 2 == 0 ) :
		isEven = True
	else :
		isEven = False
	for i in range ( 0 , l , 2 ) :
		if ( isEven ) :
			s1 = s [ i ] + s1
			s1 += s [ i + 1 ]
		else :
			if ( l - i > 1 ) :
				s1 += s [ i ]
				s1 = s [ i + 1 ] + s1
			else :
				s1 += s [ i ]
	return s1
if __name__ == ' _ _ main _ _ ' :
	s = " eekgs "
	print ( decodeMedianString ( s ) )