def flatten(data):
    """Returns a flattened version of a list.

    Courtesy of https://stackoverflow.com/a/12472564

    Args:
        data (`tuple` or `list`): Input data

    Returns:
        `list`
    """
    if not data:
        return data

    if type(data[0]) in (list, tuple):
        return list(flatten(data[0])) + list(flatten(data[1:]))

    return list(data[:1]) + list(flatten(data[1:]))
Returns a flattened version of a list.

    Courtesy of https://stackoverflow.com/a/12472564

    Args:
        data (`tuple` or `list`): Input data

    Returns:
        `list`