Iterate from 0 till the size of the string
for k in range ( len ( s ) ) : NEW_LINE INDENT if ( s [ k ] == chr ( i + ord ( '0' ) ) and prev1 == chr ( j + ord ( '0' ) ) ) : NEW_LINE INDENT prev1 = s [ k ] NEW_LINE DEDENT DEDENT