from typing import List
from typing import Tuple


def group(lst: List, n: int) -> List[Tuple]:
    """
    Splits a list into tuples of length n
    https://stackoverflow.com/a/15480610/36061

    eg
    a = 'Moscow|city|London|city|Royston Vasey|vilage'
    list(group(a.split('|'), 2))
    gives
    [('Moscow', 'city'), ('London', 'city'), ('Royston Vasey', 'vilage')]


    Parameters
    ----------
    lst : a list
    n : int, number of entries per tuple

    Returns
    ------
    list of tuples, each of length n
    """
    r = []
    for i in range(0, len(lst), n):
        val = lst[i:i + n]
        if len(val) == n:
            r.append(tuple(val))
    return r