n and n1 are used to check for substring without considering the case of the letters in w by comparing the difference of ASCII values
ch = w [ i ] NEW_LINE ch1 = s [ index ] [ i - position ] NEW_LINE if ( ch >= ' a ' and ch <= ' z ' ) : NEW_LINE INDENT n = ord ( ch ) - ord ( ' a ' ) NEW_LINE DEDENT else : NEW_LINE INDENT n = ord ( ch ) - ord ( ' A ' ) NEW_LINE DEDENT if ( ch1 >= ' a ' and ch1 <= ' z ' ) : NEW_LINE INDENT n1 = ord ( ch1 ) - ord ( ' a ' ) NEW_LINE DEDENT else : NEW_LINE INDENT n1 = ord ( ch1 ) - ord ( ' A ' ) NEW_LINE DEDENT if ( n != n1 ) : NEW_LINE INDENT same = False NEW_LINE DEDENT