Checking for all combinations
if ( ( s [ i ] == '0' and previous_state == 0 ) or ( s [ i ] == '1' and previous_state == 3 ) ) : NEW_LINE INDENT final_state = 1 NEW_LINE DEDENT elif ( ( s [ i ] == '0' and previous_state == 3 ) or ( s [ i ] == '1' and previous_state == 0 ) ) : NEW_LINE INDENT final_state = 2 NEW_LINE DEDENT elif ( ( s [ i ] == '0' and previous_state == 1 ) or ( s [ i ] == '1' and previous_state == 2 ) ) : NEW_LINE INDENT final_state = 0 NEW_LINE DEDENT elif ( ( s [ i ] == '0' and previous_state == 2 ) or ( s [ i ] == '1' and previous_state == 1 ) ) : NEW_LINE INDENT final_state = 3 NEW_LINE DEDENT