def minmax(x):
    """
    Returns a tuple containing the min and max value of the iterable `x`.

    .. note:: this also works if `x` is a generator.

    >>> minmax([1, -2, 3, 4, 1, 0, -2, 5, 1, 0])
    (-2, 5)
    """

    (minItem, maxItem) = (None, None)
    for item in x:
        if (minItem is None) or (item < minItem):
            minItem = item
        if (maxItem is None) or (item > maxItem):
            maxItem = item
    return (minItem, maxItem)