human
Give me a code to check if a given number is Fancy and the other steps required given the following:
Check if a given number is Fancy | Python 3 program to find if a given number is fancy or not ..
To store mappings of fancy pair characters . For example 6 is paired with 9 and 9 is paired with 6..
Find number of digits in given number.
Traverse from both ends , and compare characters one by one.
If current characters at both ends are not fancy pairs.
Driver program"
How can the above be solved in Python?
assistant
#Here is code to check if a given number is Fancy and the other steps required.
 def isFancy ( num ) :
	fp = { }
	fp [ '0' ] = '0'
	fp [ '1' ] = '1'
	fp [ '6' ] = '9'
	fp [ '8' ] = '8'
	fp [ '9' ] = '6'
	n = len ( num )
	l = 0
	r = n - 1
	while ( l <= r ) :
		if ( num [ l ] not in fp or fp [ num [ l ] ] != num [ r ] ) :
			return False
		l += 1
		r -= 1
	return True
if __name__ == " _ _ main _ _ " :
	st = "9088806"
	if isFancy ( st ) :
		print ( " Yes " )
	else :
		print ( " No " )