import random


def rand_trial(tgt_num,min_itv,max_itv):
    """
    Generate a list of number, which would be used to make sure that there
    are some filler sentence(s) between any 2 target sentences.
    
    Parameters
    ----------
    tgt_num: Int
             The number of target sentences
    
    min_itv: Int
             The minimum number of filler sentences between 2 target sentences
             max_itv >= 1.
             
    max_itv: Int
             The maximum number of filler sentences between 2 target sentences.
             Note that "tgt_num*max_itv <= the number of filler sentences".
             
    Returns
    ----------
    li     : List
             "li" contains 2 types of numbers, one is the number zero, the other
             is numbers that are greater than or equal to  one. Zero indicates
             a target sentence. Numbers greater than or equal to 0 indicate the 
             number of filler sentences between 2 targets. eg.
            
             "[2, 0, 1, 0, 1, 0, 2, 0, 2, 0]" would helps generating a trial 
             list in which 2 filler sentences is at the beginning of the trial
             list, then 1 target sentence, then 1 filler sentence, etc.
             
        
    
    """
    li=[]
    for i in range(tgt_num):
        #Randomly choose the interval between 2 target sentences
        rand_itv=random.randint(min_itv,max_itv)
        li.append(rand_itv)
        li.append(0)
    return li