human
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  .
Iterate through bits of n till we find a set bit i & n will be non - zero only when ' i ' and ' n ' have a set bit at same position.
Unset current bit and set the next bit in 'i  .
increment position.
Driver Code"
Solution in Python:
assistant
#Here is code to find position of the only set bit and the other steps required.
 def isPowerOfTwo ( n ) :
	return ( True if ( n > 0 and ( ( n & ( n - 1 ) ) > 0 ) ) else False ) ;
def findPosition ( n ) :
	if ( isPowerOfTwo ( n ) == True ) :
		return - 1 ;
	i = 1 ;
	pos = 1 ;
	while ( ( i & n ) == 0 ) :
		i = i << 1 ;
		pos += 1 ;
	return pos ;
n = 16 ;
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 ) ;