<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def method_delegate(**methods):
 """ Construct a renderer that delegates based on the request's HTTP method. """


    methods = {k.upper(): v for k, v in iteritems(methods)}

    if PY3:
        methods = {k.encode("utf-8"): v for k, v in iteritems(methods)}

    def render(request):
        renderer = methods.get(request.method)
        if renderer is None:
            return Response(code=405)
        return renderer(request)
    return render