def find_ngrams(single_words, n):
    """
    Args:
        single_words: list of words in the text, in the order they appear in the text
            all words are made of lowercase characters
        n:            length of 'n-gram' window
    Returns:
        list of n-grams from input text list, or an empty list if n is not a valid value
    """
    
    ngram_list = []
    if n <= 0 or n > len(single_words):
        return []
    else:
        for i in range(len(single_words) - n +1):
            p = single_words[i:n+i]# variable p getting a list of ngrams from single words
            t = " ".join(p) # varibale t creating a string from the p
            ngram_list.append(t)
        return ngram_list