def clean_line(string, stop_char):
    """
            # clean_line :: String char -> String
            Receives a String and a 'stop_char'.
            Scans the string backwards and cuts at the first 'stop_char', returning the new String
            ex:
                clean_line("this is a # string", '#')  --> "this is a "
                clean_line("[ X ] > [ V ]  # V eh a palavra vazia.", '#')  --> "[ X ] > [ V ]  "
                clean_line("[ X ] > [ V ]  # V eh a # palavra vazia.", '#')  --> "[ X ] > [ V ]  # V eh a "
    """
    pos = len(string) - 1
    cut_pos = 0
    stop_char_found = False

    while stop_char_found is False and pos >= 0:

        if string[pos] == stop_char:
            cut_pos = pos + 1
            stop_char_found = True

        pos -= 1

    return string[:cut_pos]