human
Write me a code to find position of the only set bit and the other steps required given the following:
Find position of the only set bit | A utility function to check whether n is power of 2 or not.
Returns position of the only set bit in 'n  .
One by one move the only set bit to right till it reaches end.
increment count of shifts.
Driver program to test above function"
How can the above be solved in Python?
assistant
#Here is code to find position of the only set bit and the other steps required.
 def isPowerOfTwo ( n ) :
	return ( n and ( not ( n & ( n - 1 ) ) ) )
def findPosition ( n ) :
	if not isPowerOfTwo ( n ) :
		return - 1
	count = 0
	while ( n ) :
		n = n >> 1
		count += 1
	return count
if __name__ == " _ _ main _ _ " :
	n = 0
	pos = findPosition ( n )
	if pos == - 1 :
		print ( " n ▁ = " , n , " Invalid ▁ number " )
	else :
		print ( " n ▁ = " , n , " Position " , pos )
	n = 12
	pos = findPosition ( n )
	if pos == - 1 :
		print ( " n ▁ = " , n , " Invalid ▁ number " )
	else :
		print ( " n ▁ = " , n , " Position " , pos )
	n = 128
	pos = findPosition ( n )
	if pos == - 1 :
		print ( " n ▁ = " , n , " Invalid ▁ number " )
	else :
		print ( " n ▁ = " , n , " Position " , pos )