import io
import contextlib


def capture_output(func, *args):
    """Return captured stdout output of func when called"""
    stdout = io.StringIO()

    # Context manager to fetch all stdout output into value stdoout
    with contextlib.redirect_stdout(stdout):
        func(*args)

    # Return sanitized stdout output value of func
    return stdout.getvalue().strip()