def find_between(line: str, char1: str, char2: str, nth_time=1):
    """
    Goes through the given line, looking for what's between char1 and char2.
    Returns substring found. If char1...char2 is present more than once in
    line, the nth_time parameter can be used to specify which occurrence should
    be returned. The char1 and char2 are NOT returned along with the substring.

    Parameter
    ---------
    line : str
        Line where substring shall be looked for.
    char1 : str
        Char (single char!) at the beginning of the desired substring.
    char2 : str
        Char (single char!) at the end of the desired substring.
    nth_time : int, optional
        Which occurrence of the char1...char2 pattern must be returned.
        if no number is given, nth_time is set to 1.

    Returns
    -------
    between : str
        Substring found between char1 and char2.
        Does NOT include char1 and char2.

    """
    if line.count(char1) < nth_time or line.count(char2) < nth_time:
        raise ValueError('bad arguments given to find_between()')
    between = ''
    this_time = 1
    line = iter(line)
    char = next(line)
    while True:
        while char != char1:
            char = next(line)
        char = next(line)
        while char != char2:
            between += char
            char = next(line)
        if this_time == nth_time:
            return between
        else:
            this_time += 1
            between = ''
