Check for the " proposed " element to be only differing by one
if a [ pos ] == ai : NEW_LINE INDENT continue NEW_LINE DEDENT elif a [ pos ] + 1 == ai or a [ pos ] - 1 == ai : NEW_LINE INDENT temp += 1 NEW_LINE DEDENT else : NEW_LINE