human
Alternating Numbers | Function to check if a string is of the form even odd even odd ....
Function to check if a string is of the form odd even odd even ....
Function to check if n is an alternating number.
Given Number N.
Function Call"
Solution in Python:
 ... Give me a code to alternating Numbers and the other steps required?
assistant
#Here is code to alternating Numbers and the other steps required.
 def isEvenOddForm ( s ) :
	n = len ( s )
	for i in range ( n ) :
		if ( i % 2 == 0 and int ( s [ i ] ) % 2 != 0 ) :
			return False
		if ( i % 2 == 1 and int ( s [ i ] ) % 2 != 1 ) :
			return False
	return True
def isOddEvenForm ( s ) :
	n = len ( s )
	for i in range ( n ) :
		if ( i % 2 == 0 and int ( s [ i ] ) % 2 != 1 ) :
			return False
		if ( i % 2 == 1 and int ( s [ i ] ) % 2 != 0 ) :
			return False
	return True
def isAlternating ( n ) :
	s = str ( n )
	return ( isEvenOddForm ( s ) or isOddEvenForm ( s ) )
N = 129
if ( isAlternating ( N ) ) :
	print ( " Yes " )
else :
	print ( " No " )