import random


def random_newlines(words_list, nb_of_newlines):
    """
    Distribute randomly a given number of newline characters in a list of words.

    Input:
    -words_list         list of strings
    -nb_of_newlines     integer
    Output:
    -words_list         list of strings
    """

    period_indexes = []

    for i, word in enumerate(words_list):

        if "." in word:

            period_indexes.append(i + 1)

    if nb_of_newlines > len(period_indexes):
        nb_of_newlines = len(period_indexes)

    newline_indexes = random.sample(period_indexes, nb_of_newlines)

    for index in newline_indexes:

        words_list.insert(index, "\n\n")

    return words_list