human
Complete the below
def capture(func):

    ''''Return the printed output of func().
    `func` should be a function without arguments that produces output with
    print statements.
    >>> from sympy.utilities.iterables import capture
    >>> from sympy import pprint
    >>> from sympy.abc import x
    >>> def foo():
    ...     print(\'hello world!\')
    >>> \'hello\' in capture(foo) # foo, not foo()
    True
    >>> capture(lambda: pprint(2/x))
    \'2\n-\nx\n\''
    '''

=====
What is a Python code to print statements?
assistant
#Here is Python code to print statements.
    from sympy.core.compatibility import StringIO
    import sys
    stdout = sys.stdout
    sys.stdout = file = StringIO()
    try:
        func()
    finally:
        sys.stdout = stdout
    return file.getvalue()