[lang-ref] ( break_out_of_nested_loop ) ( python )

def test_break_out_of_nested_loop():
    pytest.skip('Not supported')
def test_break_out_of_nested_loop_alternative():
    # make it function

    def search_value_with_break(limit_value):
        current_value = 0
        for i in range(10):
            for j in range(10):
                current_value = i * 10 + j
                if current_value == limit_value:
                    break # breaks only internal loop

        # outer loop continues, so current_value end up as the last value 99
        return current_value

    def search_value_with_return(limit_value):
        current_value = 0
        for i in range(10):
            for j in range(10):
                current_value = i * 10 + j
                if current_value == limit_value:
                    return current_value

        raise Error('unexpected')

    v = search_value_with_break(25)
    assert v == 99 # `break` exits only the inner loop, so the outer loop continues.

    v = search_value_with_return(25)
    assert v == 25