human
Complete this python program:
def literal_dumps(obj, prettyprint=False, indent=4):
assistant
#Here is the Python code you requested.

    """Write obj into a string as a python literal.
    """
    memo = {}
    NoneType = type(None)
    def check(obj):
        if (type(obj) in [int, float, bool, NoneType, str, bytes]):
            return True
        if (id(obj) in memo):
            raise ValueError('{0}    is    a    recursive    structure'.format(obj))
        memo[id(obj)] = obj
        if (type(obj) in [list, tuple]):
            return all(map(check, obj))
        elif (type(obj) is dict):
            return all(map(check, chain(iter(obj.keys()), iter(obj.values()))))
        else:
            raise TypeError('{0}    can    not    be    serialized    as    a    python    literal'.format(type(obj)))
    check(obj)
    if prettyprint:
        return pprint.pformat(obj, indent=indent)
    else:
        return repr(obj)