from csc148_queue import Queue


def list_queue(list_: list, q: Queue) -> list:
    """
    Return a list of non-list elements of list_ after processing them
    through q.

    This is the function you implemented in the handout,
    except for it returns a list instead of printing.
    (instead of printing "1 3 5", it would return [1, 3, 5])

    You do *NOT* have to touch this.
    """
    result_list = []
    for i in list_:
        q.add(i)
    while not q.is_empty():
        i = q.remove()
        if not isinstance(i, list):
            result_list.append(i)
        else:
            for j in i:
                q.add(j)
    return result_list


if __name__ == "__main__":
    new_list = list_queue(["a", ["b", ["c", "d"], "e", "f"], "g"], Queue())
    #
    # TODO: Type in literal elements for answer_list, *without* using list_queue,
    # so that True would be printed.  We give you the correct first element, "a"
    # You'll not be able to run this class (you will get "permission denied!")
    #
    answer_list = ["a", "g", "b", "e", "f", "c", "d"]
    print(new_list == answer_list)
