def nth_line(src, lineno):
    """
    Compute the starting index of the n-th line (where n is 1-indexed)

    >>> nth_line("aaa\\nbb\\nc", 2)
    4
    """
    assert lineno >= 1
    pos = 0
    for _ in range(lineno - 1):
        pos = src.find("\n", pos) + 1
    return pos

    Compute the starting index of the n-th line (where n is 1-indexed)

    >>> nth_line("aaa\nbb\nc", 2)
    4
    
tests/cpu/expecttest.py