def encode_query(query, vocabulary):
    """Takes a textual query and a vocabulary (mapping from words to integers), returns the encoded query in a list.
       If a word is not in the dictionary, the function returns False.

    Args:
        query (list): A textual query
        vocabulary (dict): Mapping from all words

    Returns:
        [list or bool]: the encoded query in a list or False
    """
    encoded = []
    for token in query:
        if token in vocabulary:
            encoded.append(vocabulary[token])
        else:
            return False
    return encoded