human
Write me a code to check if a number has bits in alternate pattern and the other steps required given the following:
Check if a number has bits in alternate pattern | Set 1 | Returns true if n has alternate bit pattern else false.
Store last bit.
Traverse through remaining bits.
If current bit is same as previous.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to check if a number has bits in alternate pattern and the other steps required.
 def findPattern ( n ) :
	prev = n % 2
	n = n // 2
	while ( n > 0 ) :
		curr = n % 2
		if ( curr == prev ) :
			return False
		prev = curr
		n = n // 2
	return True
n = 10
print ( " Yes " ) if ( findPattern ( n ) ) else print ( " No " )