from typing import Iterable


def flatten(nestedlist: Iterable) -> list:
    """Flatten a nested list."""
    newlist = []
    for item in nestedlist:
        if isinstance(item, list):
            newlist.extend(flatten(item))
        else:
            newlist.append(item)
    return newlist