human
Give me a code to program to insert dashes between two adjacent odd digits in given Number and the other steps required given the following:
Program to insert dashes between two adjacent odd digits in given Number | Function to check if char ch is odd or not.
Function to insert dash - between any 2 consecutive digit in string str.
Traverse the string character by character.
Compare every consecutive character with the odd value.
Print the resultant string.
Given number in form of string.
Function call"
Solution in Python:
assistant
#Here is code to program to insert dashes between two adjacent odd digits in given Number and the other steps required.
 def checkOdd ( ch ) :
	return ( ( ord ( ch ) - 48 ) & 1 )
def Insert_dash ( num_str ) :
	result_str = num_str
	x = 0
	while ( x < len ( num_str ) - 1 ) :
		if ( checkOdd ( num_str [ x ] ) and checkOdd ( num_str [ x + 1 ] ) ) :
			result_str = ( result_str [ : x + 1 ] + ' - ' + result_str [ x + 1 : ] )
			num_str = result_str
			x += 1
		x += 1
	return result_str
str = "1745389"
print ( Insert_dash ( str ) )