Check if a number ends with another number or not | Function to check if B is a suffix of A or not ; Convert numbers into strings ; Find the lengths of strings s1 and s2 ; Base Case ; Traverse the strings s1 & s2 ; If at any index characters are unequals then return false ; Return true ; Given numbers ; Function Call ; If B is a suffix of A , then print " Yes "
def checkSuffix ( A , B ) : NEW_LINE INDENT s1 = str ( A ) ; NEW_LINE s2 = str ( B ) ; NEW_LINE n1 = len ( s1 ) NEW_LINE n2 = len ( s2 ) NEW_LINE if ( n1 < n2 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT for i in range ( n2 ) : NEW_LINE INDENT if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT return True ; NEW_LINE DEDENT A = 12345 NEW_LINE B = 45 ; NEW_LINE result = checkSuffix ( A , B ) ; NEW_LINE if ( result ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT