human
Check if a binary string contains consecutive same or not | Function that returns true is str is valid.
Assuming the string is binary If any two consecutive characters are equal then the string is invalid.
If the string is alternating.
Driver code"
How can the above be solved in Python?
 ... Give me a code to check if a binary string contains consecutive same or not and the other steps required?
assistant
#Here is code to check if a binary string contains consecutive same or not and the other steps required.
 def isValid ( string , length ) :
	for i in range ( 1 , length ) :
		if string [ i ] == string [ i - 1 ] :
			return False
	return True
if __name__ == " _ _ main _ _ " :
	string = "0110"
	length = len ( string )
	if isValid ( string , length ) :
		print ( " Valid " )
	else :
		print ( " Invalid " )