def get_tcon(v, index):
    """Gets the list indices in L of the tensors that have index as their
    leg.
    """
    tcon = []
    for i, inds in enumerate(v):
        if index in inds:
            tcon.append(i)
    l = len(tcon)
    if l > 2:
        raise ValueError(
            'In ncon.get_tcon, more than two tensors share a contraction index.'
            )
    elif l < 1:
        raise ValueError(
            'In ncon.get_tcon, less than one tensor share a contraction index.'
            )
    elif l == 1:
        how_many = v[tcon[0]].count(index)
        if how_many != 2:
            raise ValueError(
                'In ncon.get_tcon, a trace index is listed != 2 times for the same tensor.'
                )
    return tcon
