human
Print Concatenation of Zig | Function for zig - zag Concatenation.
Check is n is less or equal to 1.
Iterate rowNum from 0 to n - 1.
Iterate i till s . length ( ) - 1.
Check is rowNum is 0 or n - 1.
Driver Code"
How can the above be solved in Python?
 Write me a code to print Concatenation of Zig and the other steps required?
assistant
#Here is code to print Concatenation of Zig and the other steps required.
 def zigZagConcat ( s , n ) :
	if ( n <= 1 ) :
		return s
	result = " "
	for rowNum in range ( n ) :
		i = rowNum
		up = True
		while ( i < len ( s ) ) :
			result += s [ i ]
			if ( rowNum == 0 or rowNum == n - 1 ) :
				i += ( 2 * n - 2 )
			else :
				if ( up ) :
					i += ( 2 * ( n - rowNum ) - 2 )
				else :
					i += rowNum * 2
				up ^= True
	return result
str = " GEEKSFORGEEKS "
n = 3
print ( zigZagConcat ( str , n ) )